Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FUNCTION Z_ASG_FN_SEARCH_TEST.
- *"----------------------------------------------------------------------
- *"*"Local Interface:
- *" IMPORTING
- *" REFERENCE(WA_EMP) TYPE ZASG_EMP
- *" TABLES
- *" Z_EMPID STRUCTURE SELOPT
- *"----------------------------------------------------------------------
- DATA : emp_name LIKE ZASG_EMP-name,
- emp_amount LIKE ZASG_SAL-amount,
- emp_currency LIKE ZASG_SAL-currency,
- where_statement TYPE STRING,
- STR2 TYPE STRING, STR3 TYPE STRING,
- counter TYPE INT1 VALUE 0,
- errors TYPE INT1 VALUE 0.
- IF NOT Z_EMPID IS INITIAL.
- LOOP AT Z_EMPID.
- * WRITE : / 'welcome'.
- * WRITE : / Z_EMPID-low.
- counter = counter + 1.
- IF Z_EMPID-OPTION = 'EQ'.
- where_statement = 'e~id = Z_EMPID-LOW'.
- CONCATENATE where_statement STR2 INTO where_statement.
- ELSEIF Z_EMPID-OPTION = 'NE'.
- STR2 = 'e~id <> Z_EMPID-LOW'.
- CONCATENATE where_statement STR2 INTO where_statement.
- ELSEIF Z_EMPID-OPTION = 'GT'.
- STR2 = 'e~id > Z_EMPID-LOW'.
- CONCATENATE where_statement STR2 INTO where_statement.
- ELSEIF Z_EMPID-OPTION = 'LT'.
- STR2 = 'e~id < Z_EMPID-LOW'.
- CONCATENATE where_statement STR2 INTO where_statement.
- ELSEIF Z_EMPID-OPTION = 'GE'.
- STR2 = 'e~id >= Z_EMPID-LOW'.
- CONCATENATE where_statement STR2 INTO where_statement.
- ELSEIF Z_EMPID-OPTION = 'LE'.
- STR2 = 'e~id <= Z_EMPID-LOW'.
- CONCATENATE where_statement STR2 INTO where_statement.
- ELSEIF Z_EMPID-OPTION = 'BT'.
- STR2 = 'e~id BETWEEN Z_EMPID-LOW AND Z_EMPID-HIGH'.
- CONCATENATE where_statement STR2 INTO where_statement.
- ENDIF.
- IF NOT wa_emp-name is INITIAL.
- IF where_statement is INITIAL.
- STR2 = 'e~name = wa_emp-name'.
- CONCATENATE where_statement STR2 INTO where_statement.
- ELSE.
- STR2 = 'AND e~name = wa_emp-name'.
- CONCATENATE where_statement STR2 INTO where_statement SEPARATED BY ' '.
- ENDIF.
- ENDIF.
- IF NOT wa_emp-empposition is INITIAL.
- IF where_statement is INITIAL.
- STR2 = 'e~empposition = wa_emp-empposition'.
- CONCATENATE where_statement STR2 INTO where_statement.
- ELSE.
- STR2 = 'AND e~empposition = wa_emp-empposition'.
- CONCATENATE where_statement STR2 INTO where_statement SEPARATED BY ' '.
- ENDIF.
- ENDIF.
- WRITE : / where_statement.
- SELECT e~name s~amount s~currency
- INTO (emp_name,emp_amount,emp_currency)
- FROM (
- ZASG_EMP AS e
- INNER JOIN ZASG_SAL AS s ON e~id = s~empid
- )
- WHERE (where_statement).
- WRITE : / emp_name , emp_amount , emp_currency.
- ENDSELECT.
- * If no id is found.
- IF SY-SUBRC <> 0.
- errors = errors + 1.
- ENDIF.
- ENDLOOP.
- ELSE.
- IF NOT wa_emp-name is INITIAL.
- IF where_statement is INITIAL.
- STR2 = 'e~name = wa_emp-name'.
- CONCATENATE where_statement STR2 INTO where_statement.
- ELSE.
- STR2 = 'AND e~name = wa_emp-name'.
- CONCATENATE where_statement STR2 INTO where_statement SEPARATED BY ' '.
- ENDIF.
- ENDIF.
- IF NOT wa_emp-empposition is INITIAL.
- IF where_statement is INITIAL.
- STR2 = 'e~empposition = wa_emp-empposition'.
- CONCATENATE where_statement STR2 INTO where_statement.
- ELSE.
- STR2 = 'AND e~empposition = wa_emp-empposition'.
- CONCATENATE where_statement STR2 INTO where_statement SEPARATED BY ' '.
- ENDIF.
- ENDIF.
- SELECT e~name s~amount s~currency
- INTO (emp_name,emp_amount,emp_currency)
- FROM (
- ZASG_EMP AS e
- INNER JOIN ZASG_SAL AS s ON e~id = s~empid
- )
- WHERE (where_statement).
- WRITE : / emp_name , emp_amount , emp_currency.
- ENDSELECT.
- ENDIF.
- *
- *
- *
- *
- **if errors = counter.
- **MESSAGE ID 'ZINSERTION_ERRORS' TYPE 'I' NUMBER '007'.
- **ENDIF.
- ENDFUNCTION.
Add Comment
Please, Sign In to add comment