Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FUNCTION ZFI_DISPOSAL_REQ_INQUERY.
- *"----------------------------------------------------------------------
- *"*"Local Interface:
- *" IMPORTING
- *" REFERENCE(I_NOT_ASSIGNED) TYPE CHAR1 DEFAULT 'N'
- *" REFERENCE(I_FA_SPECIALIST) TYPE XUBNAME OPTIONAL
- *" TABLES
- *" REQ STRUCTURE ZFI_DISP_REQ_STRUCT
- *" ZZCOMPANY_CODE STRUCTURE SELOPT
- *" ZZCOST_CENTER STRUCTURE SELOPT
- *" ZZSR_NUMBER STRUCTURE SELOPT
- *" ZZDATE STRUCTURE SELOPT
- *" ZZSERVICE_TYPE STRUCTURE SELOPT
- *" ZZRQSTTS STRUCTURE SELOPT
- *" I_ANLN1 STRUCTURE SELOPT OPTIONAL
- *" I_ANLN2 STRUCTURE SELOPT OPTIONAL
- *"----------------------------------------------------------------------
- DATA : R_ANLN1 TYPE TABLE OF SELOPT,
- R_ANLN2 TYPE TABLE OF SELOPT.
- IF I_ANLN1[] IS NOT INITIAL.
- MOVE-CORRESPONDING I_ANLN1[] TO R_ANLN1[].
- ENDIF.
- IF I_ANLN2[] IS NOT INITIAL.
- MOVE-CORRESPONDING I_ANLN2[] TO R_ANLN2[].
- ENDIF.
- DATA : L_WA type ZFI_DISP_REQ_STRUCT,
- CURR_INDEX type i.
- IF I_NOT_ASSIGNED eq 'Y'.
- 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
- INTO CORRESPONDING FIELDS OF TABLE req
- FROM ZFI_DISPOSAL_REQ as r
- LEFT JOIN ZFI_LOOKUP as l1 ON l1~ZZLKUPID = r~ZZSERVICE_TYPE
- LEFT JOIN ZFI_LOOKUP as l2 ON l2~ZZLKUPID = r~ZZRQSTTS
- LEFT JOIN T001 as T ON T~BUKRS = r~ZZCOMPANY_CODE
- WHERE ( r~ZZCOMPANY_CODE in ZZCOMPANY_CODE )
- and ( r~ZZCOST_CENTER in ZZCOST_CENTER )
- and ( r~ZZSR_NUMBER in ZZSR_NUMBER )
- and ( r~ZZDATE in ZZDATE )
- and ( r~ZZSERVICE_TYPE in ZZSERVICE_TYPE )
- and ( r~ZZRQSTTS in ZZRQSTTS )
- and ( r~ZZASSIGNED_TO = SPACE ).
- ELSEIF I_NOT_ASSIGNED eq 'S'.
- 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
- INTO CORRESPONDING FIELDS OF TABLE req
- FROM ZFI_DISPOSAL_REQ as r
- LEFT JOIN ZFI_LOOKUP as l1 ON l1~ZZLKUPID = r~ZZSERVICE_TYPE
- LEFT JOIN ZFI_LOOKUP as l2 ON l2~ZZLKUPID = r~ZZRQSTTS
- LEFT JOIN T001 as T ON T~BUKRS = r~ZZCOMPANY_CODE
- WHERE ( r~ZZCOMPANY_CODE in ZZCOMPANY_CODE )
- and ( r~ZZCOST_CENTER in ZZCOST_CENTER )
- and ( r~ZZSR_NUMBER in ZZSR_NUMBER )
- and ( r~ZZDATE in ZZDATE )
- and ( r~ZZSERVICE_TYPE in ZZSERVICE_TYPE )
- and ( r~ZZRQSTTS in ZZRQSTTS )
- and ( r~ZZASSIGNED_TO = i_fa_specialist ).
- ELSEIF I_NOT_ASSIGNED eq 'A'.
- DATA : TMP_REQ LIKE TABLE OF REQ ,
- WA_TMP_REQ LIKE LINE OF REQ,
- TMP_ASS TYPE TABLE OF ZFI_DISPOSAL_ASS ,
- WA_TMP_ASS TYPE ZFI_DISPOSAL_ASS.
- 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
- INTO CORRESPONDING FIELDS OF TABLE TMP_REQ
- FROM ZFI_DISPOSAL_REQ as r
- LEFT JOIN ZFI_LOOKUP as l1 ON l1~ZZLKUPID = r~ZZSERVICE_TYPE
- LEFT JOIN ZFI_LOOKUP as l2 ON l2~ZZLKUPID = r~ZZRQSTTS
- LEFT JOIN T001 as T ON T~BUKRS = r~ZZCOMPANY_CODE
- WHERE ( r~ZZCOMPANY_CODE in ZZCOMPANY_CODE )
- and ( r~ZZCOST_CENTER in ZZCOST_CENTER )
- and ( r~ZZSR_NUMBER in ZZSR_NUMBER )
- and ( r~ZZDATE in ZZDATE )
- and ( r~ZZSERVICE_TYPE in ZZSERVICE_TYPE )
- and ( r~ZZRQSTTS in ZZRQSTTS ).
- SELECT Z1~ZZID AS ZZREQ_ID Z2~ANLN1 Z2~ANLN2 INTO CORRESPONDING FIELDS OF TABLE TMP_ASS
- FROM ZFI_DISPOSAL_REQ AS Z1
- LEFT JOIN ZFI_DISPOSAL_ASS AS Z2
- ON Z1~ZZID = Z2~ZZREQ_ID.
- CLEAR REQ.
- LOOP AT TMP_REQ INTO WA_TMP_REQ .
- 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 .
- APPEND WA_TMP_REQ TO REQ.
- EXIT.
- ENDLOOP.
- ENDLOOP.
- *old
- * 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
- * INTO CORRESPONDING FIELDS OF TABLE req
- * FROM ZFI_DISPOSAL_REQ as r
- * LEFT JOIN ZFI_LOOKUP as l1 ON l1~ZZLKUPID = r~ZZSERVICE_TYPE
- * LEFT JOIN ZFI_LOOKUP as l2 ON l2~ZZLKUPID = r~ZZRQSTTS
- * LEFT JOIN T001 as T ON T~BUKRS = r~ZZCOMPANY_CODE
- * WHERE ( r~ZZCOMPANY_CODE in ZZCOMPANY_CODE )
- * and ( r~ZZCOST_CENTER in ZZCOST_CENTER )
- * and ( r~ZZSR_NUMBER in ZZSR_NUMBER )
- * and ( r~ZZDATE in ZZDATE )
- * and ( r~ZZSERVICE_TYPE in ZZSERVICE_TYPE )
- * and ( r~ZZRQSTTS in ZZRQSTTS )
- * and ( r~ZZID IN ( SELECT ZZREQ_ID FROM ZFI_DISPOSAL_ASS
- * WHERE ANLN1 IN R_ANLN1
- * AND ANLN2 IN R_ANLN2 ) )." get request ids that belongs to specific given assets
- ELSE.
- 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
- INTO CORRESPONDING FIELDS OF TABLE req
- FROM ZFI_DISPOSAL_REQ as r
- LEFT JOIN ZFI_LOOKUP as l1 ON l1~ZZLKUPID = r~ZZSERVICE_TYPE
- LEFT JOIN ZFI_LOOKUP as l2 ON l2~ZZLKUPID = r~ZZRQSTTS
- LEFT JOIN T001 as T ON T~BUKRS = r~ZZCOMPANY_CODE
- WHERE ( r~ZZCOMPANY_CODE in ZZCOMPANY_CODE )
- and ( r~ZZCOST_CENTER in ZZCOST_CENTER )
- and ( r~ZZSR_NUMBER in ZZSR_NUMBER )
- and ( r~ZZDATE in ZZDATE )
- and ( r~ZZSERVICE_TYPE in ZZSERVICE_TYPE )
- and ( r~ZZRQSTTS in ZZRQSTTS ) .
- endif.
- " sum assets ABC values
- loop at req into L_WA.
- CURR_INDEX = sy-TABIX.
- select sum( ZZABC_VALUE ) into L_WA-ZZTOTAL_AMOUNT
- from ZFI_DISPOSAL_ASS
- where ZZREQ_ID = L_WA-zzid.
- MODIFY req INDEX CURR_INDEX from L_WA TRANSPORTING ZZTOTAL_AMOUNT.
- ENDLOOP.
- ENDFUNCTION.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement