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
- *" REFERENCE(WA_SAL) TYPE ZASG_SAL
- *" 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,
- it_tab TYPE TABLE OF SELOPT WITH HEADER LINE,
- wa_emp_sal TYPE ZASG_EMP.
- IF Z_EMPID[] IS NOT INITIAL.
- LOOP AT Z_EMPID.
- counter = counter + 1.
- it_tab-low = Z_EMPID-LOW.
- it_tab-high = Z_EMPID-HIGH.
- it_tab-option = Z_EMPID-OPTION.
- it_tab-sign = Z_EMPID-SIGN.
- APPEND it_tab.
- clear it_tab.
- IF where_statement is INITIAL.
- where_statement = 'e~id IN it_tab'.
- 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.
- 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.
- 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 SY-SUBRC <> 0.
- errors = errors + 1.
- 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