Advertisement
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 Z_EMPID[] IS NOT INITIAL.
- LOOP AT Z_EMPID.
- counter = counter + 1.
- IF Z_EMPID-SIGN = 'I'.
- 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.
- ELSEIF Z_EMPID-SIGN = 'E'.
- IF Z_EMPID-OPTION = 'EQ'.
- STR2 = '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 NOT BETWEEN Z_EMPID-LOW AND Z_EMPID-HIGH'.
- CONCATENATE where_statement STR2 INTO where_statement.
- ENDIF.
- 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.
- 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 AND where_statement IS NOT INITIAL.
- MESSAGE ID 'ZINSERTION_ERRORS' TYPE 'I' NUMBER '012'.
- ENDIF.
- ENDFUNCTION.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement