INPUT SCREEN
OUTPUT SCREEN
*&---------------------------------------------------------------------*
*& Report ZSD_DELIVERY_VALUE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZSD_DELIVERY_VALUE.
TYPE-pools : slis.
TABLES: LIKP.
TYPES : BEGIN OF T_LIKP,
VBELN TYPE VBELN_VL,
LFDAT TYPE LFDAT_V,
KUNNR TYPE KUNWE,
NAME1 TYPE NAME1_GP,
ORT01 type ORT01_GP,
END OF T_LIKP,
BEGIN OF T_LIPS,
VBELN TYPE LIKP-VBELN,
POSNR TYPE POSNR_VL ,
PSTYV TYPE PSTYV_VL ,
MATNR TYPE MATNR ,
WERKS TYPE WERKS_D,
LGORT TYPE LGORT_D,
CHARG TYPE CHARG_D ,
LFIMG TYPE LFIMG,
MEINS TYPE MEINS ,
VGBEL TYPE VGBEL ,
VGPOS TYPE VGPOS,
MAKTX TYPE MAKTX ,
VTWEG type VTWEG,
VTEXT TYPE VTXTK ,
END OF T_LIPS,
BEGIN OF T_VBAP,
VBELN TYPE VBELN_VA,
POSNR TYPE POSNR_VA ,
MATNR TYPE MATNR,
CHARG TYPE CHARG_D,
KWMENG TYPE KWMENG,
NETWR TYPE NETWR_AP,
MWSBP TYPE MWSBP ,
END OF T_VBAP,
BEGIN OF T_FINAL,
VBELN TYPE VBELN_VL,
POSNR TYPE POSNR_VL ,
LFDAT TYPE LFDAT_V,
KUNNR TYPE KUNWE,
NAME1 TYPE NAME1_GP,
ORT01 type ORT01_GP,
VTWEG type VTWEG,
VTEXT TYPE VTXTK ,
VGBEL TYPE VGBEL ,
VGPOS TYPE VGPOS,
MATNR TYPE MATNR ,
MAKTX TYPE MAKTX ,
KWMENG TYPE KWMENG,
NETWR TYPE NETWR_AP,
MWSBP TYPE MWSBP ,
LFIMG TYPE LFIMG,
DSVAL TYPE NETWR_AP,
END OF T_FINAL,
BEGIN OF t_lfa1,
KUNNR TYPE KUNWE,
NAME1 TYPE NAME1_GP,
END OF t_lfa1.
DATA : I_LIKP TYPE STANDARD TABLE OF T_LIKP WITH HEADER LINE,
I_LIPS TYPE STANDARD TABLE OF T_LIPS WITH HEADER LINE,
I_VBAP TYPE STANDARD TABLE OF T_VBAP WITH HEADER LINE,
I_FINAL TYPE STANDARD TABLE OF T_FINAL WITH HEADER LINE,
i_lfa1 TYPE STANDARD TABLE OF t_lfa1 WITH HEADER LINE,
I_LIKP_TEMP TYPE STANDARD TABLE OF T_LIKP WITH HEADER LINE.
DATA: W_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
SELECTION-SCREEN BEGIN OF BLOCK S_DL WITH FRAME TITLE G_TITLE.
SELECT-OPTIONS : S_VBELN FOR I_LIKP-VBELN,
S_LFDAT FOR I_LIKP-LFDAT,
S_KUNNR FOR I_LIKP-KUNNR,
s_vtweg for i_lips-vtweg.
SELECTION-SCREEN END OF BLOCK s_dl.
AT SELECTION-SCREEN on VALUE-REQUEST FOR S_VBELN-LOW.
CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
EXPORTING
TABNAME = 'LIKP'
FIELDNAME = 'VBELN'
SEARCHHELP = 'VMVL'
* SHLPPARAM = ' '
* DYNPPROG = ' '
* DYNPNR = ' '
DYNPROFIELD = 'S_VBELN-LOW'
* STEPL = 0
* VALUE = ' '
* MULTIPLE_CHOICE = ' '
* DISPLAY = ' '
* SUPPRESS_RECORDLIST = ' '
* CALLBACK_PROGRAM = ' '
* CALLBACK_FORM = ' '
* SELECTION_SCREEN = ' '
* IMPORTING
* USER_RESET =
* TABLES
* RETURN_TAB =
* EXCEPTIONS
* FIELD_NOT_FOUND = 1
* NO_HELP_FOR_FIELD = 2
* INCONSISTENT_HELP = 3
* NO_VALUES_FOUND = 4
* OTHERS = 5
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
AT SELECTION-SCREEN on VALUE-REQUEST FOR S_VBELN-HIGH.
CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
EXPORTING
TABNAME = 'LIKP'
FIELDNAME = 'VBELN'
SEARCHHELP = 'VMVL'
* SHLPPARAM = ' '
* DYNPPROG = ' '
* DYNPNR = ' '
DYNPROFIELD = 'S_VBELN-LOW'
* STEPL = 0
* VALUE = ' '
* MULTIPLE_CHOICE = ' '
* DISPLAY = ' '
* SUPPRESS_RECORDLIST = ' '
* CALLBACK_PROGRAM = ' '
* CALLBACK_FORM = ' '
* SELECTION_SCREEN = ' '
* IMPORTING
* USER_RESET =
* TABLES
* RETURN_TAB =
* EXCEPTIONS
* FIELD_NOT_FOUND = 1
* NO_HELP_FOR_FIELD = 2
* INCONSISTENT_HELP = 3
* NO_VALUES_FOUND = 4
* OTHERS = 5
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
AT SELECTION-SCREEN on VALUE-REQUEST FOR S_KUNNR-LOW.
CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
EXPORTING
TABNAME = 'RF02D'
FIELDNAME = 'KUNNR'
* SEARCHHELP = 'VMVL'
* SHLPPARAM = ' '
* DYNPPROG = ' '
* DYNPNR = ' '
DYNPROFIELD = 'S_KUNNR-LOW'
* STEPL = 0
* VALUE = ' '
* MULTIPLE_CHOICE = ' '
* DISPLAY = ' '
* SUPPRESS_RECORDLIST = ' '
* CALLBACK_PROGRAM = ' '
* CALLBACK_FORM = ' '
* SELECTION_SCREEN = ' '
* IMPORTING
* USER_RESET =
* TABLES
* RETURN_TAB =
* EXCEPTIONS
* FIELD_NOT_FOUND = 1
* NO_HELP_FOR_FIELD = 2
* INCONSISTENT_HELP = 3
* NO_VALUES_FOUND = 4
* OTHERS = 5
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
AT SELECTION-SCREEN on VALUE-REQUEST FOR S_KUNNR-HIGH.
CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
EXPORTING
TABNAME = 'RF02D'
FIELDNAME = 'KUNNR'
* SEARCHHELP = 'VMVL'
* SHLPPARAM = ' '
* DYNPPROG = ' '
* DYNPNR = ' '
DYNPROFIELD = 'S_KUNNR-LOW'
* STEPL = 0
* VALUE = ' '
* MULTIPLE_CHOICE = ' '
* DISPLAY = ' '
* SUPPRESS_RECORDLIST = ' '
* CALLBACK_PROGRAM = ' '
* CALLBACK_FORM = ' '
* SELECTION_SCREEN = ' '
* IMPORTING
* USER_RESET =
* TABLES
* RETURN_TAB =
* EXCEPTIONS
* FIELD_NOT_FOUND = 1
* NO_HELP_FOR_FIELD = 2
* INCONSISTENT_HELP = 3
* NO_VALUES_FOUND = 4
* OTHERS = 5
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
START-OF-SELECTION .
PERFORM GET_DATA.
perform process_data.
PERFORM bulid_alv.
end-of-SELECTION.
PERFORM display_alv.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA .
SELECT a~VBELN
a~LFDAT
a~KUNNR
b~NAME1
b~ORT01
FROM LIKP as a INNER JOIN KNa1 as b on a~kunnr = b~kunnr
INTO TABLE I_LIKP
WHERE a~VBELN IN S_VBELN
AND a~LFDAT IN S_LFDAT
AND a~KUNNR IN S_KUNNR.
*SELECT VBELN
* LFDAT
* KUNNR
* FROM LIKP
* INTO TABLE I_LIKP
* WHERE VBELN IN S_VBELN
* AND LFDAT IN S_LFDAT
* AND KUNNR IN S_KUNNR.
IF SY-SUBRC = 0.
*I_LIKP_TEMP[] = I_LIKP[].
*
*SORT I_LIKP_TEMP ASCENDING BY KUNNR.
*
*DELETE ADJACENT DUPLICATES FROM I_LIKP_TEMP COMPARING KUNNR.
*SELECT KUNNR
* NAME1
* FROM LFA1
* INTO TABLE I_LFA1
* FOR ALL ENTRIES IN I_LIKP_TEMP
* WHERE KUNNR = I_LIKP_TEMP-KUNNR.
*
* LOOP AT I_LFA1.
*
* I_LIKP-KUNNR = I_LFA1-KUNNR.
* MODIFY I_LIKP FROM I_LIKP TRANSPORTING NAME1 WHERE KUNNR =
*I_LFA1-KUNNR.
*
* ENDLOOP.
SELECT A~VBELN
A~POSNR
A~PSTYV
A~MATNR
A~WERKS
A~LGORT
A~CHARG
A~LFIMG
A~MEINS
A~VGBEL
A~VGPOS
b~MAKTX
a~vtweg
c~VTEXT
FROM LIPS as a INNER JOIN makt AS B ON A~MATNR = B~MATNR
INNER JOIN tvtwt as c on a~vtweg = c~vtweg
INTO TABLE I_LIPS
FOR ALL ENTRIES IN I_LIKP
WHERE A~VBELN = I_LIKP-VBELN
and a~vtweg in s_vtweg
and c~SPRAS = 'EN'
AND B~SPRAS = 'EN'.
IF SY-SUBRC = 0.
SELECT VBELN
POSNR
MATNR
CHARG
KWMENG
NETWR
MWSBP
FROM VBAP
INTO TABLE I_VBAP
FOR ALL ENTRIES IN I_LIPS
WHERE VBELN = I_LIPS-VGBEL
AND POSNR = I_LIPS-VGPOS.
ELSE.
MESSAGE 'No records found' TYPE 'E'.
ENDIF.
ELSE.
MESSAGE 'No records found' TYPE 'E'.
ENDIF.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form process_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM process_data .
LOOP AT i_lips.
i_final-VBELN = i_lips-vbeln.
i_final-posnr = i_lips-posnr.
i_final-vgbel = i_lips-vgbel.
i_final-vgpos = i_lips-vgpos.
i_final-MATNR = i_lips-matnr.
i_final-lfimg = i_lips-lfimg.
I_FINAL-MAKTX = I_LIPS-MAKTX.
i_final-VTWEG = i_lips-VTWEG.
i_final-VTEXT = i_lips-VTEXT.
READ TABLE i_likp with key VBELN = I_lips-VBELN.
IF SY-SUBRC = 0.
I_FINAL-KUNNR = I_LIKP-KUNNR.
I_FINAL-NAME1 = I_LIKP-NAME1.
I_FINAL-LFDAT = I_LIKP-LFDAT.
i_final-ORT01 = i_likp-ORT01.
ENDIF.
READ TABLE I_VBAP WITH KEY VBELN = I_LIPS-VGBEL
POSNR = I_LIPS-VGPOS.
IF SY-SUBRC = 0.
I_FINAL-KWMENG = I_VBAP-KWMENG.
I_FINAL-NETWR = I_VBAP-NETWR.
I_FINAL-MWSBP = I_VBAP-MWSBP.
ENDIF.
I_FINAL-DSVAL = ( I_FINAL-NETWR + I_FINAL-MWSBP ) / I_FINAL-KWMENG.
I_FINAL-DSVAL = I_FINAL-DSVAL * I_FINAL-LFIMG.
APPEND I_FINAL.
ENDLOOP.
ENDFORM. " process_data
*&---------------------------------------------------------------------*
*& Form bulid_alv
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM bulid_alv .
REFRESH I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-FIELDNAME = 'VBELN'.
W_FIELDCAT-TABNAME = 'I_FINAL'.
W_FIELDCAT-SELTEXT_L = 'Delivery Number'.
* W_FIELDCAT-COL_POS = 1.
W_FIELDCAT-NO_ZERO = 'X'.
* W_FIELDCAT-OUTPUTLEN = 5.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-FIELDNAME = 'KUNNR'.
W_FIELDCAT-TABNAME = 'I_FINAL'.
W_FIELDCAT-SELTEXT_L = 'Customer Code'.
* W_FIELDCAT-COL_POS = 1.
W_FIELDCAT-NO_ZERO = 'X'.
* W_FIELDCAT-OUTPUTLEN = 5.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-FIELDNAME = 'NAME1'.
W_FIELDCAT-TABNAME = 'I_FINAL'.
W_FIELDCAT-SELTEXT_L = 'Customer Name'.
* W_FIELDCAT-COL_POS = 1.
W_FIELDCAT-NO_ZERO = 'X'.
* W_FIELDCAT-OUTPUTLEN = 5.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-FIELDNAME = 'ORT01'.
W_FIELDCAT-TABNAME = 'I_FINAL'.
W_FIELDCAT-SELTEXT_L = 'City'.
* W_FIELDCAT-COL_POS = 1.
W_FIELDCAT-NO_ZERO = 'X'.
* W_FIELDCAT-OUTPUTLEN = 5.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-FIELDNAME = 'VTWEG'.
W_FIELDCAT-TABNAME = 'I_FINAL'.
W_FIELDCAT-SELTEXT_L = 'Distribution Code'.
W_FIELDCAT-seltext_m = 'Dist Code'.
W_FIELDCAT-seltext_s = 'D code'.
* W_FIELDCAT-COL_POS = 1.
W_FIELDCAT-NO_ZERO = 'X'.
* W_FIELDCAT-OUTPUTLEN = 5.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-FIELDNAME = 'VTEXT'.
W_FIELDCAT-TABNAME = 'I_FINAL'.
W_FIELDCAT-SELTEXT_L = 'Distribution Channel'.
W_FIELDCAT-seltext_m = 'Dist Channel'.
W_FIELDCAT-seltext_s = 'D Channel'.
* W_FIELDCAT-COL_POS = 1.
W_FIELDCAT-NO_ZERO = 'X'.
* W_FIELDCAT-OUTPUTLEN = 5.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-FIELDNAME = 'LFDAT'.
W_FIELDCAT-TABNAME = 'I_FINAL'.
W_FIELDCAT-SELTEXT_L = 'Delivery date'.
* W_FIELDCAT-COL_POS = 1.
W_FIELDCAT-NO_ZERO = 'X'.
* W_FIELDCAT-OUTPUTLEN = 5.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-FIELDNAME = 'VGBEL'.
W_FIELDCAT-TABNAME = 'I_FINAL'.
W_FIELDCAT-SELTEXT_L = 'Sales Order Number'.
* W_FIELDCAT-COL_POS = 1.
W_FIELDCAT-NO_ZERO = 'X'.
* W_FIELDCAT-OUTPUTLEN = 5.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-FIELDNAME = 'VGPOS'.
W_FIELDCAT-TABNAME = 'I_FINAL'.
W_FIELDCAT-SELTEXT_L = 'Line Item'.
* W_FIELDCAT-COL_POS = 1.
W_FIELDCAT-NO_ZERO = 'X'.
* W_FIELDCAT-OUTPUTLEN = 5.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-FIELDNAME = 'MATNR'.
W_FIELDCAT-TABNAME = 'I_FINAL'.
W_FIELDCAT-SELTEXT_L = 'Material Number'.
* W_FIELDCAT-COL_POS = 1.
W_FIELDCAT-NO_ZERO = 'X'.
* W_FIELDCAT-OUTPUTLEN = 5.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-FIELDNAME = 'KWMENG'.
W_FIELDCAT-TABNAME = 'I_FINAL'.
W_FIELDCAT-SELTEXT_L = 'Sales Order Quantity'.
* W_FIELDCAT-COL_POS = 1.
W_FIELDCAT-NO_ZERO = 'X'.
* W_FIELDCAT-OUTPUTLEN = 5.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-FIELDNAME = 'NETWR'.
W_FIELDCAT-TABNAME = 'I_FINAL'.
W_FIELDCAT-SELTEXT_L = 'Net Value'.
* W_FIELDCAT-COL_POS = 1.
W_FIELDCAT-NO_ZERO = 'X'.
* W_FIELDCAT-OUTPUTLEN = 5.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-FIELDNAME = 'MWSBP'.
W_FIELDCAT-TABNAME = 'I_FINAL'.
W_FIELDCAT-SELTEXT_L = 'Total Tax Sales Order Value'.
* W_FIELDCAT-COL_POS = 1.
W_FIELDCAT-NO_ZERO = 'X'.
* W_FIELDCAT-OUTPUTLEN = 5.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-FIELDNAME = 'LFIMG'.
W_FIELDCAT-TABNAME = 'I_FINAL'.
W_FIELDCAT-SELTEXT_L = 'Delivery Quantity'.
* W_FIELDCAT-COL_POS = 1.
W_FIELDCAT-NO_ZERO = 'X'.
* W_FIELDCAT-OUTPUTLEN = 5.
APPEND W_FIELDCAT TO I_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-FIELDNAME = 'DSVAL'.
W_FIELDCAT-TABNAME = 'I_FINAL'.
W_FIELDCAT-SELTEXT_L = 'Delivery Value'.
* W_FIELDCAT-COL_POS = 1.
W_FIELDCAT-NO_ZERO = 'X'.
* W_FIELDCAT-OUTPUTLEN = 5.
APPEND W_FIELDCAT TO I_FIELDCAT.
ENDFORM. " bulid_alv
*&---------------------------------------------------------------------*
*& Form display_alv
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_alv .
DATA : G_SYUCOMM TYPE SY-UCOMM.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
* I_CALLBACK_PF_STATUS_SET = 'STDPOPBX_FULLSCREEN'
* I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
IT_FIELDCAT = I_FIELDCAT
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = I_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " display_alv
Ecorptrainings.com provides sap sd in hyderabad with best faculties on real time projects. We give the best online trainingamong the sap sd in Hyderabad.
ReplyDeleteClassroom Training in Hyderabad India
This comment has been removed by the author.
ReplyDeletethe blog you posted is very useful to us thanks for posting this blog...................Please contact us for Oracle Fusion SCM Training details in our Erptree Training Institute
ReplyDelete
ReplyDeleteThanks for sharing the details! thanks for sharing information,nice article.
i would like to more information from your side!
please added more then tips!Am working in
websphere training in hyderabad
Nice article, interesting to read…
ReplyDeleteThanks for sharing the useful information
servicenow implementation certification
technical support services
ReplyDeleteReally this is a very useful blog.
Thank you
UI Developer Training
ReplyDeleteGreat post . thanks for sharing a clear step by step process on getting in the nice.thank you.
Your content is very impressive and thanks for sharing this article. its very useful.
ReplyDeleteservicenow training