Advertisement
yaramohamed78

select option test -v6 - FM

Jan 22nd, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 2.82 KB | None | 0 0
  1. FUNCTION Z_ASG_FN_SEARCH_TEST.
  2. *"----------------------------------------------------------------------
  3. *"*"Local Interface:
  4. *"  IMPORTING
  5. *"     REFERENCE(WA_EMP) TYPE  ZASG_EMP
  6. *"     REFERENCE(WA_SAL) TYPE  ZASG_SAL
  7. *"  TABLES
  8. *"      Z_EMPID STRUCTURE  SELOPT
  9. *"----------------------------------------------------------------------
  10. DATA : emp_name LIKE ZASG_EMP-NAME,
  11.        emp_amount LIKE ZASG_SAL-amount,
  12.        emp_currency LIKE ZASG_SAL-CURRENCY,
  13.        where_statement TYPE STRING,
  14.        STR2 TYPE STRING, STR3 TYPE STRING,
  15.        counter TYPE INT1 VALUE 0,
  16.        errors TYPE INT1 VALUE 0,
  17.        it_tab TYPE TABLE OF SELOPT WITH HEADER LINE,
  18.        wa_emp_sal TYPE ZASG_EMP.
  19.  
  20. IF Z_EMPID[] IS NOT INITIAL.
  21.  
  22. LOOP AT Z_EMPID.
  23. counter = counter + 1.
  24.  
  25. it_tab-low = Z_EMPID-LOW.
  26. it_tab-high = Z_EMPID-HIGH.
  27. it_tab-option = Z_EMPID-OPTION.
  28. it_tab-sign = Z_EMPID-SIGN.
  29. APPEND it_tab.
  30. clear it_tab.
  31.  
  32. IF where_statement is INITIAL.
  33. where_statement = 'e~id IN it_tab'.
  34. CONCATENATE where_statement STR2 INTO where_statement.
  35. ENDIF.
  36. IF  NOT wa_emp-NAME IS INITIAL.
  37.   IF where_statement IS INITIAL.
  38.     STR2 = 'e~name = wa_emp-name'.
  39.   CONCATENATE where_statement STR2  INTO where_statement.
  40.    ELSE.
  41.     STR2 = 'AND e~name = wa_emp-name'.
  42.   CONCATENATE where_statement STR2  INTO where_statement SEPARATED BY ' '.
  43.    ENDIF.
  44.   ENDIF.
  45.  
  46.    IF NOT wa_emp-empposition IS INITIAL.
  47.   IF where_statement IS INITIAL.
  48.     STR2 = 'e~empposition = wa_emp-empposition'.
  49.   CONCATENATE where_statement STR2  INTO where_statement.
  50.    ELSE.
  51.     STR2 = 'AND e~empposition = wa_emp-empposition'.
  52.   CONCATENATE where_statement STR2  INTO where_statement SEPARATED BY ' '.
  53.    ENDIF.
  54.   ENDIF.
  55.  
  56. ENDLOOP.
  57.  
  58. ELSE.
  59.   IF  NOT wa_emp-NAME IS INITIAL.
  60.   IF where_statement IS INITIAL.
  61.     STR2 = 'e~name = wa_emp-name'.
  62.   CONCATENATE where_statement STR2  INTO where_statement.
  63.    ELSE.
  64.     STR2 = 'AND e~name = wa_emp-name'.
  65.   CONCATENATE where_statement STR2  INTO where_statement SEPARATED BY ' '.
  66.    ENDIF.
  67.   ENDIF.
  68.  
  69.  
  70.    IF NOT wa_emp-empposition IS INITIAL.
  71.   IF where_statement IS INITIAL.
  72.     STR2 = 'e~empposition = wa_emp-empposition'.
  73.   CONCATENATE where_statement STR2  INTO where_statement.
  74.    ELSE.
  75.     STR2 = 'AND e~empposition = wa_emp-empposition'.
  76.   CONCATENATE where_statement STR2  INTO where_statement SEPARATED BY ' '.
  77.    ENDIF.
  78.   ENDIF.
  79.  
  80. ENDIF.
  81.  
  82.    SELECT e~NAME s~amount s~CURRENCY
  83.     INTO (emp_name,emp_amount,emp_currency)
  84.   FROM (
  85.     ZASG_EMP AS e
  86.     INNER JOIN ZASG_SAL AS s ON e~ID = s~empid
  87.     )
  88.     WHERE (where_statement).
  89.     WRITE : / emp_name , emp_amount , emp_currency.
  90.     ENDSELECT.
  91.  
  92.     IF  SY-SUBRC <> 0.
  93.      errors = errors + 1.
  94.      ENDIF.
  95.     IF errors = counter AND where_statement IS NOT INITIAL.
  96. MESSAGE ID 'ZINSERTION_ERRORS' TYPE 'I' NUMBER '012'.
  97. ENDIF.
  98.  
  99. ENDFUNCTION.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement