*&---------------------------------------------------------------------*
*& Report ZELVR_CSP3_4_SO_OR_PROJECT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZELVR_CSP2_4_SO_OR_PROJECT.
TYPE-POOLS : SLIS.
TABLES : PROJ, VBAK.
TYPES : BEGIN OF TY_VBAP,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
MATNR TYPE VBAP-MATNR,
KWMENG TYPE VBAP-KWMENG,
WERKS TYPE VBAP-WERKS,
PS_PSP_PNR TYPE VBAP-PS_PSP_PNR,
END OF TY_VBAP.
TYPES : BEGIN OF TY_MARA,
MATNR TYPE MARA-MATNR,
BISMT TYPE MARA-BISMT,
NTGEW TYPE MARA-NTGEW,
END OF TY_MARA.
TYPES : BEGIN OF TY_FINAL,
VBELN TYPE VBAP-VBELN,
SOSNR TYPE VBAP-POSNR,
PS_PSP_PNR TYPE CHAR50,
MATNR TYPE VBAP-MATNR,
STUFE TYPE STPOX-STUFE,
POSNR TYPE STPOX-POSNR,
IDNRK TYPE STPOX-IDNRK,
BISMT TYPE MARA-BISMT,
NTGEW TYPE MARA-NTGEW,
OJTXP TYPE STPOX-OJTXP,
POTX1 TYPE STPOX-POTX1,
POTX2 TYPE STPOX-POTX2,
POTXT TYPE CHAR100,
KWMENG TYPE VBAP-KWMENG,
MNGKO TYPE STPOX-MNGKO,
RMNGKO TYPE STPOX-MNGKO,
TMNGKO TYPE STPOX-MNGKO,
MEINS TYPE STPOX-MEINS,
POSTP TYPE STPOX-POSTP,
END OF TY_FINAL.
DATA : LT_VBAP TYPE TABLE OF TY_VBAP,
WA_VBAP TYPE TY_VBAP.
DATA : LT_MARA TYPE TABLE OF TY_MARA,
WA_MARA TYPE TY_MARA.
DATA : LT_FINAL TYPE TABLE OF TY_FINAL,
WA_FINAL TYPE TY_FINAL.
DATA : IT_FCAT TYPE TABLE OF SLIS_FIELDCAT_ALV,
WA_FCAT TYPE SLIS_FIELDCAT_ALV.
DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA : LT_STPOX TYPE TABLE OF STPOX,
LT_TEMP TYPE TABLE OF STPOX,
WA_TEMP TYPE STPOX.
DATA : LV_CAPID TYPE TC04-CAPID,
LV_DATUV TYPE STKO-DATUV,
LV_MMORY TYPE CSDATA-XFELD.
DATA : TDID TYPE TDID.
DATA : TDOBJECT TYPE TDOBJECT.
DATA : TDSPRAS TYPE TDSPRAS.
DATA : TDNAME TYPE TDOBNAME.
DATA : LT_TLINE TYPE TABLE OF TLINE.
DATA : WA_TLINE TYPE TLINE.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_VBELN FOR VBAK-VBELN NO INTERVALS.
SELECTION-SCREEN END OF BLOCK B1.
START-OF-SELECTION.
PERFORM VALIDATE.
PERFORM GET_DATA.
PERFORM BUILD_DATA.
PERFORM BUILD_FCAT.
PERFORM SHOW_DATA.
*&---------------------------------------------------------------------*
*& Form VALIDATE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM VALIDATE .
IF S_VBELN IS INITIAL.
MESSAGE 'Kindly provide the sale order number' TYPE 'S' DISPLAY LIKE 'E'.
STOP.
ENDIF.
ENDFORM. " VALIDATE
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA .
SELECT VBELN
POSNR
MATNR
KWMENG
WERKS
PS_PSP_PNR FROM VBAP
INTO TABLE LT_VBAP
WHERE VBELN IN S_VBELN.
IF SY-SUBRC <> 0.
MESSAGE 'No Data Found!' TYPE 'S' DISPLAY LIKE 'E'.
STOP.
ENDIF.
LV_CAPID = 'PP01'.
LV_DATUV = SY-DATUM.
LV_MMORY = '1'.
DELETE LT_VBAP WHERE PS_PSP_PNR IS INITIAL.
LOOP AT LT_VBAP INTO WA_VBAP.
CALL FUNCTION 'CS_BOM_EXPL_PSP_V1'
EXPORTING
* ALTVO = ' '
* AMIND = ' '
AUFSW = ' '
* AUMGB = ' '
* AUMNG =
* AUSKZ = ' '
* BAGRP = ' '
* BEIKZ = ' '
* BESSL = ' '
* BGIXO = ' '
* BREMS = ' '
CAPID = LV_CAPID* CHLST = ' '
* COSPR = ' '
* CUOBJ = 000000000000000
* CUOVS = 0
* CUOLS = ' '
DATUV = LV_DATUV* DELNL = ' '
* DRLDT = ' '
* DRSTP = ' '
* EHNDL = ' '
* EMENG = 0
* ERSKZ = ' '
* ERSSL = ' '
* FBSTP = ' '
* FTREL = ' '
* KNFBA = ' '
* KSBVO = ' '
MBWLS = ' '
* MDMPS = ' '
* MDNOT = ' '
MEHRS = 'X'
* MKMAT = ' '
* MKTLS = 'X'
* MMAPS = ' '
MMORY = LV_MMORY
MTNRV = WA_VBAP-MATNR* NESTP = ' '
* NLINK = ' '
* NPSTP = ' '
* PANOT = ' '
* PBSTP = ' '
* POSTP = ' '
PSPNR = WA_VBAP-PS_PSP_PNR* QVERW = ' '
* RNDKZ = ' '
* RVREL = ' '
* SANFR = ' '
* SANIN = ' '
* SANKA = ' '
* SANKO = ' '
* SANVS = ' '
* SCHGT = ' '
* SALWW = ' '
* SPLWW = ' '
* STKKZ = ' '
* STLAL = ' '
* STLAN = ' '
* STPST = 0
* SVWVO = 'X'
* VERID = ' '
* VRSVO = 'X'
WERKS = WA_VBAP-WERKS* NORVL = ' '
* IMPORTING
* TOPMAT =
* DSTST =
TABLES
STB = LT_STPOX* MATCAT =
EXCEPTIONS
ALT_NOT_FOUND = 1
CALL_INVALID = 2
MATERIAL_NOT_FOUND = 3
MISSING_AUTHORIZATION = 4
NO_BOM_FOUND = 5
NO_PLANT_DATA = 6
NO_SUITABLE_BOM_FOUND = 7
CONVERSION_ERROR = 8
OTHERS = 9
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF LT_STPOX IS NOT INITIAL.
CLEAR : WA_TEMP.
CONCATENATE WA_VBAP-VBELN WA_VBAP-POSNR WA_VBAP-MATNR INTO WA_TEMP-OJTXB SEPARATED BY ':'.
WA_TEMP-AENNR = WA_VBAP-PS_PSP_PNR.
WA_TEMP-MNGLG = WA_VBAP-KWMENG.
MODIFY LT_STPOX FROM WA_TEMP TRANSPORTING OJTXB AENNR MNGLG WHERE IDNRK IS NOT INITIAL.
APPEND LINES OF LT_STPOX TO LT_TEMP.
REFRESH LT_STPOX.
ENDIF.
CLEAR : WA_VBAP.
ENDLOOP.
IF LT_TEMP IS NOT INITIAL.
SELECT MATNR
BISMT
NTGEW FROM MARA
INTO TABLE LT_MARA
FOR ALL ENTRIES IN LT_TEMP
WHERE MATNR = LT_TEMP-IDNRK.
ELSE.
MESSAGE 'No Data Found!' TYPE 'S' DISPLAY LIKE 'E'.
STOP.
ENDIF.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form BUILD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_DATA .
TDID = 'BEST'.
TDOBJECT = 'MATERIAL'.
TDSPRAS = SY-LANGU.
LOOP AT LT_TEMP INTO WA_TEMP.
TDNAME = WA_TEMP-IDNRK.
CALL FUNCTION 'READ_TEXT'
EXPORTING
ID = TDID
LANGUAGE = TDSPRAS
NAME = TDNAME
OBJECT = TDOBJECT
TABLES
LINES = LT_TLINE
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
SPLIT WA_TEMP-OJTXB AT ':' INTO WA_FINAL-VBELN WA_FINAL-SOSNR WA_FINAL-MATNR.
CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
EXPORTING
INPUT = WA_TEMP-AENNR
IMPORTING
OUTPUT = WA_FINAL-PS_PSP_PNR
.
WA_FINAL-KWMENG = WA_TEMP-MNGLG.
WA_FINAL-STUFE = WA_TEMP-STUFE.
WA_FINAL-POSNR = WA_TEMP-POSNR.
WA_FINAL-IDNRK = WA_TEMP-IDNRK.
READ TABLE LT_MARA INTO WA_MARA WITH KEY MATNR = WA_FINAL-IDNRK.
IF SY-SUBRC = 0.
WA_FINAL-BISMT = WA_MARA-BISMT.
WA_FINAL-NTGEW = WA_MARA-NTGEW.
ENDIF.
WA_FINAL-OJTXP = WA_TEMP-OJTXP.
WA_FINAL-POTX1 = WA_TEMP-POTX1.
WA_FINAL-POTX2 = WA_TEMP-POTX2.
READ TABLE LT_TLINE INTO WA_TLINE INDEX 1.
IF SY-SUBRC = 0.
WA_FINAL-POTXT = WA_TLINE-TDLINE.
ENDIF.
WA_FINAL-MNGKO = WA_TEMP-MNGKO.
WA_FINAL-RMNGKO = WA_FINAL-KWMENG * WA_FINAL-MNGKO.
WA_FINAL-TMNGKO = WA_FINAL-NTGEW * WA_FINAL-RMNGKO.
WA_FINAL-MEINS = WA_TEMP-MEINS.
WA_FINAL-POSTP = WA_TEMP-POSTP.
APPEND WA_FINAL TO LT_FINAL.
CLEAR : WA_FINAL, WA_TEMP, WA_MARA, WA_TLINE.
REFRESH : LT_TLINE.
ENDLOOP.
ENDFORM. " BUILD_DATA
*&---------------------------------------------------------------------*
*& Form BUILD_FCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_FCAT .
DATA: LV_CNT TYPE SY-TABIX.
WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
WA_LAYOUT-ZEBRA = 'X'.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'VBELN'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Sale Order No.'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'SOSNR'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Sale Order Item No.'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'PS_PSP_PNR'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'WBS No.'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'MATNR'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Material No.'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'KWMENG'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Sale order Quantity'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'STUFE'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Level'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'POSNR'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Item No.'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'IDNRK'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Object ID'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'BISMT'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Old Material No.'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'OJTXP'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Object Description'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'POTX1'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Item Text Line 1'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'POTX2'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Item Text Line 2'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'POTXT'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'PO Text'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'MNGKO'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Quantity'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'RMNGKO'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Required Quantity'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'MEINS'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Unit of Measure'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'NTGEW'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Net Weight'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'TMNGKO'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Total Weight'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'POSTP'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Item category'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
ENDFORM. " BUILD_FCAT
*&---------------------------------------------------------------------*
*& Form SHOW_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SHOW_DATA .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = ''
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FCAT
I_DEFAULT = 'X'
TABLES
T_OUTTAB = LT_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. " SHOW_DATA
*& Report ZELVR_CSP3_4_SO_OR_PROJECT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZELVR_CSP2_4_SO_OR_PROJECT.
TYPE-POOLS : SLIS.
TABLES : PROJ, VBAK.
TYPES : BEGIN OF TY_VBAP,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
MATNR TYPE VBAP-MATNR,
KWMENG TYPE VBAP-KWMENG,
WERKS TYPE VBAP-WERKS,
PS_PSP_PNR TYPE VBAP-PS_PSP_PNR,
END OF TY_VBAP.
TYPES : BEGIN OF TY_MARA,
MATNR TYPE MARA-MATNR,
BISMT TYPE MARA-BISMT,
NTGEW TYPE MARA-NTGEW,
END OF TY_MARA.
TYPES : BEGIN OF TY_FINAL,
VBELN TYPE VBAP-VBELN,
SOSNR TYPE VBAP-POSNR,
PS_PSP_PNR TYPE CHAR50,
MATNR TYPE VBAP-MATNR,
STUFE TYPE STPOX-STUFE,
POSNR TYPE STPOX-POSNR,
IDNRK TYPE STPOX-IDNRK,
BISMT TYPE MARA-BISMT,
NTGEW TYPE MARA-NTGEW,
OJTXP TYPE STPOX-OJTXP,
POTX1 TYPE STPOX-POTX1,
POTX2 TYPE STPOX-POTX2,
POTXT TYPE CHAR100,
KWMENG TYPE VBAP-KWMENG,
MNGKO TYPE STPOX-MNGKO,
RMNGKO TYPE STPOX-MNGKO,
TMNGKO TYPE STPOX-MNGKO,
MEINS TYPE STPOX-MEINS,
POSTP TYPE STPOX-POSTP,
END OF TY_FINAL.
DATA : LT_VBAP TYPE TABLE OF TY_VBAP,
WA_VBAP TYPE TY_VBAP.
DATA : LT_MARA TYPE TABLE OF TY_MARA,
WA_MARA TYPE TY_MARA.
DATA : LT_FINAL TYPE TABLE OF TY_FINAL,
WA_FINAL TYPE TY_FINAL.
DATA : IT_FCAT TYPE TABLE OF SLIS_FIELDCAT_ALV,
WA_FCAT TYPE SLIS_FIELDCAT_ALV.
DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA : LT_STPOX TYPE TABLE OF STPOX,
LT_TEMP TYPE TABLE OF STPOX,
WA_TEMP TYPE STPOX.
DATA : LV_CAPID TYPE TC04-CAPID,
LV_DATUV TYPE STKO-DATUV,
LV_MMORY TYPE CSDATA-XFELD.
DATA : TDID TYPE TDID.
DATA : TDOBJECT TYPE TDOBJECT.
DATA : TDSPRAS TYPE TDSPRAS.
DATA : TDNAME TYPE TDOBNAME.
DATA : LT_TLINE TYPE TABLE OF TLINE.
DATA : WA_TLINE TYPE TLINE.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_VBELN FOR VBAK-VBELN NO INTERVALS.
SELECTION-SCREEN END OF BLOCK B1.
START-OF-SELECTION.
PERFORM VALIDATE.
PERFORM GET_DATA.
PERFORM BUILD_DATA.
PERFORM BUILD_FCAT.
PERFORM SHOW_DATA.
*&---------------------------------------------------------------------*
*& Form VALIDATE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM VALIDATE .
IF S_VBELN IS INITIAL.
MESSAGE 'Kindly provide the sale order number' TYPE 'S' DISPLAY LIKE 'E'.
STOP.
ENDIF.
ENDFORM. " VALIDATE
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA .
SELECT VBELN
POSNR
MATNR
KWMENG
WERKS
PS_PSP_PNR FROM VBAP
INTO TABLE LT_VBAP
WHERE VBELN IN S_VBELN.
IF SY-SUBRC <> 0.
MESSAGE 'No Data Found!' TYPE 'S' DISPLAY LIKE 'E'.
STOP.
ENDIF.
LV_CAPID = 'PP01'.
LV_DATUV = SY-DATUM.
LV_MMORY = '1'.
DELETE LT_VBAP WHERE PS_PSP_PNR IS INITIAL.
LOOP AT LT_VBAP INTO WA_VBAP.
CALL FUNCTION 'CS_BOM_EXPL_PSP_V1'
EXPORTING
* ALTVO = ' '
* AMIND = ' '
AUFSW = ' '
* AUMGB = ' '
* AUMNG =
* AUSKZ = ' '
* BAGRP = ' '
* BEIKZ = ' '
* BESSL = ' '
* BGIXO = ' '
* BREMS = ' '
CAPID = LV_CAPID* CHLST = ' '
* COSPR = ' '
* CUOBJ = 000000000000000
* CUOVS = 0
* CUOLS = ' '
DATUV = LV_DATUV* DELNL = ' '
* DRLDT = ' '
* DRSTP = ' '
* EHNDL = ' '
* EMENG = 0
* ERSKZ = ' '
* ERSSL = ' '
* FBSTP = ' '
* FTREL = ' '
* KNFBA = ' '
* KSBVO = ' '
MBWLS = ' '
* MDMPS = ' '
* MDNOT = ' '
MEHRS = 'X'
* MKMAT = ' '
* MKTLS = 'X'
* MMAPS = ' '
MMORY = LV_MMORY
MTNRV = WA_VBAP-MATNR* NESTP = ' '
* NLINK = ' '
* NPSTP = ' '
* PANOT = ' '
* PBSTP = ' '
* POSTP = ' '
PSPNR = WA_VBAP-PS_PSP_PNR* QVERW = ' '
* RNDKZ = ' '
* RVREL = ' '
* SANFR = ' '
* SANIN = ' '
* SANKA = ' '
* SANKO = ' '
* SANVS = ' '
* SCHGT = ' '
* SALWW = ' '
* SPLWW = ' '
* STKKZ = ' '
* STLAL = ' '
* STLAN = ' '
* STPST = 0
* SVWVO = 'X'
* VERID = ' '
* VRSVO = 'X'
WERKS = WA_VBAP-WERKS* NORVL = ' '
* IMPORTING
* TOPMAT =
* DSTST =
TABLES
STB = LT_STPOX* MATCAT =
EXCEPTIONS
ALT_NOT_FOUND = 1
CALL_INVALID = 2
MATERIAL_NOT_FOUND = 3
MISSING_AUTHORIZATION = 4
NO_BOM_FOUND = 5
NO_PLANT_DATA = 6
NO_SUITABLE_BOM_FOUND = 7
CONVERSION_ERROR = 8
OTHERS = 9
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF LT_STPOX IS NOT INITIAL.
CLEAR : WA_TEMP.
CONCATENATE WA_VBAP-VBELN WA_VBAP-POSNR WA_VBAP-MATNR INTO WA_TEMP-OJTXB SEPARATED BY ':'.
WA_TEMP-AENNR = WA_VBAP-PS_PSP_PNR.
WA_TEMP-MNGLG = WA_VBAP-KWMENG.
MODIFY LT_STPOX FROM WA_TEMP TRANSPORTING OJTXB AENNR MNGLG WHERE IDNRK IS NOT INITIAL.
APPEND LINES OF LT_STPOX TO LT_TEMP.
REFRESH LT_STPOX.
ENDIF.
CLEAR : WA_VBAP.
ENDLOOP.
IF LT_TEMP IS NOT INITIAL.
SELECT MATNR
BISMT
NTGEW FROM MARA
INTO TABLE LT_MARA
FOR ALL ENTRIES IN LT_TEMP
WHERE MATNR = LT_TEMP-IDNRK.
ELSE.
MESSAGE 'No Data Found!' TYPE 'S' DISPLAY LIKE 'E'.
STOP.
ENDIF.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form BUILD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_DATA .
TDID = 'BEST'.
TDOBJECT = 'MATERIAL'.
TDSPRAS = SY-LANGU.
LOOP AT LT_TEMP INTO WA_TEMP.
TDNAME = WA_TEMP-IDNRK.
CALL FUNCTION 'READ_TEXT'
EXPORTING
ID = TDID
LANGUAGE = TDSPRAS
NAME = TDNAME
OBJECT = TDOBJECT
TABLES
LINES = LT_TLINE
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
SPLIT WA_TEMP-OJTXB AT ':' INTO WA_FINAL-VBELN WA_FINAL-SOSNR WA_FINAL-MATNR.
CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
EXPORTING
INPUT = WA_TEMP-AENNR
IMPORTING
OUTPUT = WA_FINAL-PS_PSP_PNR
.
WA_FINAL-KWMENG = WA_TEMP-MNGLG.
WA_FINAL-STUFE = WA_TEMP-STUFE.
WA_FINAL-POSNR = WA_TEMP-POSNR.
WA_FINAL-IDNRK = WA_TEMP-IDNRK.
READ TABLE LT_MARA INTO WA_MARA WITH KEY MATNR = WA_FINAL-IDNRK.
IF SY-SUBRC = 0.
WA_FINAL-BISMT = WA_MARA-BISMT.
WA_FINAL-NTGEW = WA_MARA-NTGEW.
ENDIF.
WA_FINAL-OJTXP = WA_TEMP-OJTXP.
WA_FINAL-POTX1 = WA_TEMP-POTX1.
WA_FINAL-POTX2 = WA_TEMP-POTX2.
READ TABLE LT_TLINE INTO WA_TLINE INDEX 1.
IF SY-SUBRC = 0.
WA_FINAL-POTXT = WA_TLINE-TDLINE.
ENDIF.
WA_FINAL-MNGKO = WA_TEMP-MNGKO.
WA_FINAL-RMNGKO = WA_FINAL-KWMENG * WA_FINAL-MNGKO.
WA_FINAL-TMNGKO = WA_FINAL-NTGEW * WA_FINAL-RMNGKO.
WA_FINAL-MEINS = WA_TEMP-MEINS.
WA_FINAL-POSTP = WA_TEMP-POSTP.
APPEND WA_FINAL TO LT_FINAL.
CLEAR : WA_FINAL, WA_TEMP, WA_MARA, WA_TLINE.
REFRESH : LT_TLINE.
ENDLOOP.
ENDFORM. " BUILD_DATA
*&---------------------------------------------------------------------*
*& Form BUILD_FCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_FCAT .
DATA: LV_CNT TYPE SY-TABIX.
WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
WA_LAYOUT-ZEBRA = 'X'.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'VBELN'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Sale Order No.'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'SOSNR'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Sale Order Item No.'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'PS_PSP_PNR'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'WBS No.'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'MATNR'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Material No.'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'KWMENG'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Sale order Quantity'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'STUFE'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Level'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'POSNR'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Item No.'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'IDNRK'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Object ID'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'BISMT'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Old Material No.'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'OJTXP'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Object Description'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'POTX1'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Item Text Line 1'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'POTX2'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Item Text Line 2'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'POTXT'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'PO Text'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'MNGKO'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Quantity'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'RMNGKO'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Required Quantity'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'MEINS'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Unit of Measure'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'NTGEW'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Net Weight'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'TMNGKO'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Total Weight'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
LV_CNT = LV_CNT + 1.
CLEAR:WA_FCAT.
WA_FCAT-FIELDNAME = 'POSTP'.
WA_FCAT-TABNAME = 'LT_FINAL'.
WA_FCAT-SELTEXT_L = 'Item category'.
WA_FCAT-COL_POS = LV_CNT.
APPEND WA_FCAT TO IT_FCAT.
ENDFORM. " BUILD_FCAT
*&---------------------------------------------------------------------*
*& Form SHOW_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SHOW_DATA .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = ''
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FCAT
I_DEFAULT = 'X'
TABLES
T_OUTTAB = LT_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. " SHOW_DATA
3 comments
commentsThanks for sharing this Information. SAP ABAP Training in Gurgaon
ReplySAP ABAP Training Course in Gurgaon
ReplyThanks for sharing this Information. for more information SAP ABAP Question
Reply