Advertisement
yaramohamed78

Untitled

Mar 15th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.19 KB | None | 0 0
  1. FUNCTION ZFI_DISPOSAL_REQ_INQUERY.
  2. *"----------------------------------------------------------------------
  3. *"*"Local Interface:
  4. *" IMPORTING
  5. *" REFERENCE(I_NOT_ASSIGNED) TYPE CHAR1 DEFAULT 'N'
  6. *" REFERENCE(I_FA_SPECIALIST) TYPE XUBNAME OPTIONAL
  7. *" TABLES
  8. *" REQ STRUCTURE ZFI_DISP_REQ_STRUCT
  9. *" ZZCOMPANY_CODE STRUCTURE SELOPT
  10. *" ZZCOST_CENTER STRUCTURE SELOPT
  11. *" ZZSR_NUMBER STRUCTURE SELOPT
  12. *" ZZDATE STRUCTURE SELOPT
  13. *" ZZSERVICE_TYPE STRUCTURE SELOPT
  14. *" ZZRQSTTS STRUCTURE SELOPT
  15. *" I_ANLN1 STRUCTURE SELOPT OPTIONAL
  16. *" I_ANLN2 STRUCTURE SELOPT OPTIONAL
  17. *"----------------------------------------------------------------------
  18. DATA : R_ANLN1 TYPE TABLE OF SELOPT,
  19. R_ANLN2 TYPE TABLE OF SELOPT.
  20.  
  21. IF I_ANLN1[] IS NOT INITIAL.
  22. MOVE-CORRESPONDING I_ANLN1[] TO R_ANLN1[].
  23. ENDIF.
  24.  
  25. IF I_ANLN2[] IS NOT INITIAL.
  26. MOVE-CORRESPONDING I_ANLN2[] TO R_ANLN2[].
  27. ENDIF.
  28.  
  29.  
  30. DATA : L_WA type ZFI_DISP_REQ_STRUCT,
  31. CURR_INDEX type i.
  32.  
  33. IF I_NOT_ASSIGNED eq 'Y'.
  34.  
  35. SELECT r~ZZID r~ZZCOMPANY_CODE r~ZZCOST_CENTER r~ZZSR_NUMBER r~ZZDATE r~ZZSERVICE_TYPE r~ZZRQSTTS r~CREA_USER r~CREA_TIME r~CHNG_USER r~CHNG_TIME r~ZZASSIGNED_TO l1~ZZDESC as ZZSERVICE_DESC l2~ZZDESC as ZZSTATUS_DESC T~BUTXT as ZZCOMPANY_NAME
  36. INTO CORRESPONDING FIELDS OF TABLE req
  37. FROM ZFI_DISPOSAL_REQ as r
  38. LEFT JOIN ZFI_LOOKUP as l1 ON l1~ZZLKUPID = r~ZZSERVICE_TYPE
  39. LEFT JOIN ZFI_LOOKUP as l2 ON l2~ZZLKUPID = r~ZZRQSTTS
  40. LEFT JOIN T001 as T ON T~BUKRS = r~ZZCOMPANY_CODE
  41. WHERE ( r~ZZCOMPANY_CODE in ZZCOMPANY_CODE )
  42. and ( r~ZZCOST_CENTER in ZZCOST_CENTER )
  43. and ( r~ZZSR_NUMBER in ZZSR_NUMBER )
  44. and ( r~ZZDATE in ZZDATE )
  45. and ( r~ZZSERVICE_TYPE in ZZSERVICE_TYPE )
  46. and ( r~ZZRQSTTS in ZZRQSTTS )
  47. and ( r~ZZASSIGNED_TO = SPACE ).
  48.  
  49.  
  50. ELSEIF I_NOT_ASSIGNED eq 'S'.
  51.  
  52. SELECT r~ZZID r~ZZCOMPANY_CODE r~ZZCOST_CENTER r~ZZSR_NUMBER r~ZZDATE r~ZZSERVICE_TYPE r~ZZRQSTTS r~CREA_USER r~CREA_TIME r~CHNG_USER r~CHNG_TIME r~ZZASSIGNED_TO l1~ZZDESC as ZZSERVICE_DESC l2~ZZDESC as ZZSTATUS_DESC T~BUTXT as ZZCOMPANY_NAME
  53. INTO CORRESPONDING FIELDS OF TABLE req
  54. FROM ZFI_DISPOSAL_REQ as r
  55. LEFT JOIN ZFI_LOOKUP as l1 ON l1~ZZLKUPID = r~ZZSERVICE_TYPE
  56. LEFT JOIN ZFI_LOOKUP as l2 ON l2~ZZLKUPID = r~ZZRQSTTS
  57. LEFT JOIN T001 as T ON T~BUKRS = r~ZZCOMPANY_CODE
  58. WHERE ( r~ZZCOMPANY_CODE in ZZCOMPANY_CODE )
  59. and ( r~ZZCOST_CENTER in ZZCOST_CENTER )
  60. and ( r~ZZSR_NUMBER in ZZSR_NUMBER )
  61. and ( r~ZZDATE in ZZDATE )
  62. and ( r~ZZSERVICE_TYPE in ZZSERVICE_TYPE )
  63. and ( r~ZZRQSTTS in ZZRQSTTS )
  64. and ( r~ZZASSIGNED_TO = i_fa_specialist ).
  65.  
  66. ELSEIF I_NOT_ASSIGNED eq 'A'.
  67.  
  68. DATA : TMP_REQ LIKE TABLE OF REQ ,
  69. WA_TMP_REQ LIKE LINE OF REQ,
  70. TMP_ASS TYPE TABLE OF ZFI_DISPOSAL_ASS ,
  71. WA_TMP_ASS TYPE ZFI_DISPOSAL_ASS.
  72.  
  73.  
  74. SELECT r~ZZID r~ZZCOMPANY_CODE r~ZZCOST_CENTER r~ZZSR_NUMBER r~ZZDATE r~ZZSERVICE_TYPE r~ZZRQSTTS r~CREA_USER r~CREA_TIME r~CHNG_USER r~CHNG_TIME r~ZZASSIGNED_TO l1~ZZDESC as ZZSERVICE_DESC l2~ZZDESC as ZZSTATUS_DESC T~BUTXT as ZZCOMPANY_NAME
  75. INTO CORRESPONDING FIELDS OF TABLE TMP_REQ
  76. FROM ZFI_DISPOSAL_REQ as r
  77. LEFT JOIN ZFI_LOOKUP as l1 ON l1~ZZLKUPID = r~ZZSERVICE_TYPE
  78. LEFT JOIN ZFI_LOOKUP as l2 ON l2~ZZLKUPID = r~ZZRQSTTS
  79. LEFT JOIN T001 as T ON T~BUKRS = r~ZZCOMPANY_CODE
  80. WHERE ( r~ZZCOMPANY_CODE in ZZCOMPANY_CODE )
  81. and ( r~ZZCOST_CENTER in ZZCOST_CENTER )
  82. and ( r~ZZSR_NUMBER in ZZSR_NUMBER )
  83. and ( r~ZZDATE in ZZDATE )
  84. and ( r~ZZSERVICE_TYPE in ZZSERVICE_TYPE )
  85. and ( r~ZZRQSTTS in ZZRQSTTS ).
  86.  
  87.  
  88. SELECT Z1~ZZID AS ZZREQ_ID Z2~ANLN1 Z2~ANLN2 INTO CORRESPONDING FIELDS OF TABLE TMP_ASS
  89. FROM ZFI_DISPOSAL_REQ AS Z1
  90. LEFT JOIN ZFI_DISPOSAL_ASS AS Z2
  91. ON Z1~ZZID = Z2~ZZREQ_ID.
  92.  
  93.  
  94. CLEAR REQ.
  95.  
  96. LOOP AT TMP_REQ INTO WA_TMP_REQ .
  97. LOOP AT TMP_ASS INTO WA_TMP_ASS WHERE ZZREQ_ID = WA_TMP_REQ-ZZID AND ANLN1 IN R_ANLN1 AND ANLN2 IN R_ANLN2 .
  98. APPEND WA_TMP_REQ TO REQ.
  99. EXIT.
  100. ENDLOOP.
  101. ENDLOOP.
  102.  
  103.  
  104.  
  105. *old
  106. * SELECT r~ZZID r~ZZCOMPANY_CODE r~ZZCOST_CENTER r~ZZSR_NUMBER r~ZZDATE r~ZZSERVICE_TYPE r~ZZRQSTTS r~CREA_USER r~CREA_TIME r~CHNG_USER r~CHNG_TIME r~ZZASSIGNED_TO l1~ZZDESC as ZZSERVICE_DESC l2~ZZDESC as ZZSTATUS_DESC T~BUTXT as ZZCOMPANY_NAME
  107. * INTO CORRESPONDING FIELDS OF TABLE req
  108. * FROM ZFI_DISPOSAL_REQ as r
  109. * LEFT JOIN ZFI_LOOKUP as l1 ON l1~ZZLKUPID = r~ZZSERVICE_TYPE
  110. * LEFT JOIN ZFI_LOOKUP as l2 ON l2~ZZLKUPID = r~ZZRQSTTS
  111. * LEFT JOIN T001 as T ON T~BUKRS = r~ZZCOMPANY_CODE
  112. * WHERE ( r~ZZCOMPANY_CODE in ZZCOMPANY_CODE )
  113. * and ( r~ZZCOST_CENTER in ZZCOST_CENTER )
  114. * and ( r~ZZSR_NUMBER in ZZSR_NUMBER )
  115. * and ( r~ZZDATE in ZZDATE )
  116. * and ( r~ZZSERVICE_TYPE in ZZSERVICE_TYPE )
  117. * and ( r~ZZRQSTTS in ZZRQSTTS )
  118. * and ( r~ZZID IN ( SELECT ZZREQ_ID FROM ZFI_DISPOSAL_ASS
  119. * WHERE ANLN1 IN R_ANLN1
  120. * AND ANLN2 IN R_ANLN2 ) )." get request ids that belongs to specific given assets
  121.  
  122. ELSE.
  123.  
  124. SELECT r~ZZID r~ZZCOMPANY_CODE r~ZZCOST_CENTER r~ZZSR_NUMBER r~ZZDATE r~ZZSERVICE_TYPE r~ZZRQSTTS r~CREA_USER r~CREA_TIME r~CHNG_USER r~CHNG_TIME r~ZZASSIGNED_TO l1~ZZDESC as ZZSERVICE_DESC l2~ZZDESC as ZZSTATUS_DESC T~BUTXT as ZZCOMPANY_NAME
  125. INTO CORRESPONDING FIELDS OF TABLE req
  126. FROM ZFI_DISPOSAL_REQ as r
  127. LEFT JOIN ZFI_LOOKUP as l1 ON l1~ZZLKUPID = r~ZZSERVICE_TYPE
  128. LEFT JOIN ZFI_LOOKUP as l2 ON l2~ZZLKUPID = r~ZZRQSTTS
  129. LEFT JOIN T001 as T ON T~BUKRS = r~ZZCOMPANY_CODE
  130. WHERE ( r~ZZCOMPANY_CODE in ZZCOMPANY_CODE )
  131. and ( r~ZZCOST_CENTER in ZZCOST_CENTER )
  132. and ( r~ZZSR_NUMBER in ZZSR_NUMBER )
  133. and ( r~ZZDATE in ZZDATE )
  134. and ( r~ZZSERVICE_TYPE in ZZSERVICE_TYPE )
  135. and ( r~ZZRQSTTS in ZZRQSTTS ) .
  136.  
  137. endif.
  138.  
  139. " sum assets ABC values
  140. loop at req into L_WA.
  141. CURR_INDEX = sy-TABIX.
  142.  
  143. select sum( ZZABC_VALUE ) into L_WA-ZZTOTAL_AMOUNT
  144. from ZFI_DISPOSAL_ASS
  145. where ZZREQ_ID = L_WA-zzid.
  146.  
  147. MODIFY req INDEX CURR_INDEX from L_WA TRANSPORTING ZZTOTAL_AMOUNT.
  148.  
  149. ENDLOOP.
  150.  
  151. ENDFUNCTION.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement