Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

PROGRAM ZMCAED_IDOC_WORKBENCH NO STANDARD PAGE HEADING

LINE-SIZE 72

LINE-COUNT 55 MESSAGE-ID YSD.

TABLES : USR21, SSCRFIELDS,EKKO,E1EDT13.*&---------------------------------------------------------------------*

*& Include ZMCAED_IDOC_WORKBENCH_TOP

*&---------------------------------------------------------------------*DATA: V_OKCODE TYPE SYUCOMM,

SO_BSTNR TYPE E1EDL41-BSTNR,

SO_WERKS TYPE E1EDL24-WERKS,

SO_PARTNER_AG TYPE E1ADRM1-PARTNER_ID ,

SO_PARTNER_ID TYPE E1ADRM1-PARTNER_ID ,

SO_NTANF TYPE E1EDT13-NTANF,

SO_CUSTO TYPE E1EDK02-BELNR,

SO_SOLD1 TYPE E1EDKA1-PARTN ,

SO_SHIP1 TYPE E1EDKA1-PARTN,

SO_PLAN1 TYPE E1EDP01-WERKS,

SO_SAPM TYPE E1EDP19-IDTNR,

SO_CUTOM TYPE E1EDP19-IDTNR,

SO_VBELN1 TYPE E1EDP19-IDTNR,

SO_PO TYPE E1EDP02-BELNR,

SO_VEN TYPE E1EDKA1-PARTN,

SO_VENIN TYPE E1EDK02-BELNR ,

SO_SAPVEN TYPE E1EDK02-BELNR ,

S0_DELIVERY TYPE E1EDL20-VBELN,

SO_BSTNR1 TYPE E1EDL41-BSTNR,

SO_WERKS1 TYPE E1EDL24-WERKS,

SO_SHIP2 TYPE E1ADRM1-PARTNER_ID ,

SO_SOLD2 TYPE E1ADRM1-PARTNER_ID,

SO_MATNR2 TYPE E1EDL24-MATNR ,*SO_MATNR TYPE E1EDL24-MATNR ,SO_PARTN3 TYPE E1EDKA1-PARTN,

SO_BELNR3 TYPE E1EDK01-BELNR,

SO_WERKS3 TYPE E1EDP01-WERKS,

SO_IDTNR3 TYPE E1EDP19-IDTNR,

SO_BELNR13 TYPE E1EDK02-BELNR,

SO_ORGID TYPE E1EDK14-ORGID,

SO_FKART TYPE E1EDK01-FKART_RL,

SO_PARTN4 TYPE E1EDKA1-PARTN ,

SO_BELNR4 TYPE E1EDK01-BELNR,

SO_BELNR5 TYPE E1EDK02-BELNR ,

SO_IDTNR4 TYPE E1EDP19-IDTNR .

* SO_MATNR TYPE E1EDL24-MATNR.

* include ZMCAED_IDOC_WORKBENCH_TOP.

TYPES : BEGIN OF TY_VBELN,

VBELN TYPE E1EDL20-VBELN,

END OF TY_VBELN.

TYPES : BEGIN OF TY_SEGMENT_LIST,

DOCNUM TYPE EDID4-DOCNUM,

SEGNUM TYPE EDID4-SEGNUM,

SEGNAM TYPE EDID4-SEGNAM,

SDATA TYPE EDID4-SDATA,

END OF TY_SEGMENT_LIST.

TYPES : BEGIN OF TY_94,

DOCNUM TYPE EDID4-DOCNUM,

DIRECT TYPE EDIDC-DIRECT,

STATUS TYPE EDIDC-STATUS,

SENPRN TYPE EDIDC-SNDPRN,

RECPRN TYPE EDIDC-RCVPRN,

RCVPOR TYPE EDIDC-RCVPOR,

MESTYP TYPE EDIDC-MESTYP,

IDOCTP TYPE EDIDC-IDOCTP,

END OF TY_94,

BEGIN OF TY_945,

DOCNUM TYPE EDID4-DOCNUM,

DIRECT TYPE EDIDC-DIRECT,

STATUS TYPE EDIDC-STATUS,

DESCRP TYPE TEDS2-DESCRP,

SENPRN TYPE EDIDC-SNDPRN,

RECPRN TYPE EDIDC-RCVPRN,

RCVPOR TYPE EDIDC-RCVPOR,

IDOCTP TYPE EDIDC-IDOCTP,

MESTYP TYPE EDIDC-MESTYP,

END OF TY_945,

BEGIN OF TY_DELDATA,

DOCNUM TYPE EDID4-DOCNUM,

VBELN TYPE E1EDL20-VBELN,

SOLD TYPE E1ADRM1-PARTNER_ID,

SHIP TYPE E1ADRM1-PARTNER_ID ,

GOODI TYPE E1EDT13-NTANF,

MATNR TYPE E1EDL24-MATNR,

WERKS TYPE E1EDL24-WERKS,

BSTNR TYPE E1EDL41-BSTNR,

END OF TY_DELDATA,

BEGIN OF TY_ORDDATA,

DOCNUM TYPE EDID4-DOCNUM,

BELNR TYPE E1EDK02-BELNR,

SOLD TYPE E1EDKA1-PARTN ,

SHIP TYPE E1EDKA1-PARTN ,

PLAN TYPE E1EDP01-WERKS,

SAPM TYPE E1EDP19-IDTNR,

CUSTPO TYPE E1EDP19-IDTNR,

SALES TYPE E1EDP19-IDTNR,

ORGID TYPE E1EDK14-ORGID,

END OF TY_ORDDATA,

BEGIN OF TY_INVDATA,

DOCNUM TYPE EDID4-DOCNUM,

BELNR TYPE E1EDP02-BELNR,

VEN TYPE E1EDKA1-PARTN,

VENIN TYPE E1EDK02-BELNR ,

SAPVEN TYPE E1EDK02-BELNR ,

FKART TYPE E1EDK01-FKART_RL,

IDTNR4 TYPE E1EDP19-IDTNR,

END OF TY_INVDATA.

DATA : TB_VBELN TYPE STANDARD TABLE OF TY_VBELN,

TB_SEGMENT_LIST TYPE STANDARD TABLE OF TY_SEGMENT_LIST,

TB_DELDATA TYPE STANDARD TABLE OF TY_DELDATA,

WA_DELDATA TYPE TY_DELDATA,

TB_ORDDATA TYPE STANDARD TABLE OF TY_ORDDATA,

WA_ORDDATA TYPE TY_ORDDATA,

TB_INVDATA TYPE STANDARD TABLE OF TY_INVDATA,

WA_INVDATA TYPE TY_INVDATA,

WA_SEGMENT_LIST TYPE TY_SEGMENT_LIST,

TB_945 TYPE STANDARD TABLE OF TY_945,

TB_9451 TYPE STANDARD TABLE OF TY_945,

TB_94 TYPE STANDARD TABLE OF TY_94,

WA_94 TYPE TY_94,

WA_945 TYPE TY_945,

WA_VBELN TYPE TY_VBELN.

DATA : LV_INB,LV_OUT.

DATA: LV_CHECK TYPE C.

DATA :SO_CR1 TYPE EKKO-AEDAT,

SO_CR2 TYPE EKKO-AEDAT,

SO_CT1 TYPE EDIDC-CRETIM,

SO_CT2 TYPE EDIDC-CRETIM,

SO_CHD1 TYPE EKKO-AEDAT,

SO_CHD2 TYPE EKKO-AEDAT,

SO_CHT1 TYPE EDIDC-CRETIM,

SO_CHT2 TYPE EDIDC-CRETIM,

V_INDX TYPE SY-TABIX,

SO_VBELN TYPE E1EDL20-VBELN,

SO_MATNR TYPE E1EDL24-MATNR ,

SELTAB(1) TYPE C,

SO_CREA TYPE WBHK-AEZEIT,

SO_CRON TYPE EKKO-AEDAT,

SO_CREL TYPE WBHK-AEZEIT,

SO_CROL TYPE EKKO-AEDAT.

DATA: BDCDATA TYPE BDCDATA OCCURS 0 WITH HEADER LINE. "#EC ..

DATA: BDCDATA1 TYPE BDCDATA OCCURS 0 WITH HEADER LINE. "#EC ..

DATA: OK_CODE TYPE SY-UCOMM,

SAVE_OK TYPE SY-UCOMM.

CONSTANTS : LC_EXIT TYPE CHAR4 VALUE 'EXIT',

PB_EXIT TYPE CHAR4 VALUE 'EXIT',

LC_NEXT TYPE CHAR4 VALUE 'NEXT',

LC_CANCEL TYPE CHAR6 VALUE 'CANCEL' . " #EC

SELECTION-SCREEN PUSHBUTTON 2(10) NEXT USER-COMMAND NEXT.

SELECTION-SCREEN:BEGIN OF BLOCK BL2 WITH FRAME TITLE TEXT-005.

PARAMETERS: SP_INB RADIOBUTTON GROUP R1 DEFAULT 'X' USER-COMMAND RUSR,

SP_OUT RADIOBUTTON GROUP R1.

SELECTION-SCREEN: SKIP 2.

PARAMETERS : SP_945 RADIOBUTTON GROUP R2 MODIF ID YAB,

SP_850 RADIOBUTTON GROUP R2 MODIF ID YAB,

SP_810 RADIOBUTTON GROUP R2 MODIF ID YAB.

SELECTION-SCREEN: SKIP 2.

PARAMETERS : SP_940 RADIOBUTTON GROUP R3 MODIF ID YBC,

SP_850O RADIOBUTTON GROUP R3 MODIF ID YBC,

SP_810O RADIOBUTTON GROUP R3 MODIF ID YBC.

SELECTION-SCREEN: END OF BLOCK BL2.

*----------------------------------------------------------------------*

* INITIALIZATION

*----------------------------------------------------------------------*

INITIALIZATION.

LV_CHECK = 'Y'.

SET PF-STATUS 'MAIN1'.

*

AT SELECTION-SCREEN.

CASE SSCRFIELDS-UCOMM.

WHEN LC_EXIT.

LEAVE TO SCREEN 1000.

WHEN LC_CANCEL.

LEAVE PROGRAM.

WHEN LC_NEXT .

IF SP_INB EQ 'X' AND SP_945 EQ 'X'.

CALL SCREEN 1008.

* elseif SP_INB eq 'X' and sp_850 EQ 'X'.

* call screen 1010.

* ELSEIF SP_INB eq 'X' and sp_810 EQ 'X'.

* call screen 1011.

ELSEIF SP_OUT EQ 'X' AND SP_940 EQ 'X'.

CALL SCREEN 1012.

* ELSEIF sp_out eq 'X' and sp_850O EQ 'X'.

* CALL SCREEN 1013.

* ELSEIF sp_out eq 'X' and sp_810O EQ 'X'.

* CALL SCREEN 1014.

ENDIF.

ENDCASE.

AT SELECTION-SCREEN OUTPUT.

IF LV_CHECK EQ 'Y'.

IF SP_INB EQ 'X'.

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'YAB'.

SCREEN-INPUT = 1.

MODIFY SCREEN.

ELSEIF SCREEN-GROUP1 = 'YBC'.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

IF SP_OUT EQ 'X'.

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'YBC'.

SCREEN-INPUT = 1.

MODIFY SCREEN.

ELSEIF SCREEN-GROUP1 = 'YAB'.

SCREEN-INPUT = 0.

MODIFY SCREEN .

ENDIF.

ENDLOOP.

ENDIF.

ENDIF.

*

*&---------------------------------------------------------------------*

*& Module USER_COMMAND_1001 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE USER_COMMAND_1001 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'CANC'.

LEAVE TO SCREEN 0.

WHEN LC_EXIT.

LEAVE TO SCREEN 0.

WHEN LC_CANCEL.

CALL SCREEN 1000.

WHEN 'SEAR'.

PERFORM READ_DATA_945.

ENDCASE.

ENDMODULE. " USER_COMMAND_1001 INPUT

*&---------------------------------------------------------------------*

*& Module USER_COMMAND_1002 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE USER_COMMAND_1002 INPUT.

CASE SSCRFIELDS-UCOMM.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'CANCEL'.

LEAVE TO SCREEN 0.

WHEN 'EXIT'.

LEAVE TO SCREEN 0.

ENDCASE.

CASE SSCRFIELDS-UCOMM.

WHEN PB_EXIT..

LEAVE TO SCREEN 0.

WHEN 'BACK'.

CALL SCREEN 1000.

WHEN 'CLEA'.

* CLEAR: SO_CREA,SO_CRON,SO_CREL,S0_CROL,SO_VBELN,SO_CUSPO,SO_PLANT,SO_SHIP,SO_SOLD,SO_GOOD,SO_MATNR.

WHEN 'SEAR'.

ENDCASE.

ENDMODULE. " USER_COMMAND_1002 INPUT

*&---------------------------------------------------------------------*

*& Module USER_COMMAND_1003 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE USER_COMMAND_1003 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'CANCEL'.

LEAVE TO SCREEN 0.

WHEN 'EXIT'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDMODULE. " USER_COMMAND_1003 INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUE_REQUEST INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUE_REQUEST INPUT.

ENDMODULE. " F4IF_VALUE_REQUEST INPUT

*&---------------------------------------------------------------------*

*& Module USER_COMMAND_1004 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE USER_COMMAND_1004 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'CANCEL'.

LEAVE TO SCREEN 0.

WHEN 'EXIT'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDMODULE. " USER_COMMAND_1004 INPUT

*&---------------------------------------------------------------------*

*& Module USER_COMMAND_1005 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE USER_COMMAND_1005 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'CANCEL'.

LEAVE TO SCREEN 0.

WHEN 'EXIT'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDMODULE. " USER_COMMAND_1005 INPUT

*&---------------------------------------------------------------------*

*& Module USER_COMMAND_1006 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE USER_COMMAND_1006 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'CANCEL'.

LEAVE TO SCREEN 0.

WHEN 'EXIT'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDMODULE. " USER_COMMAND_1006 INPUT

*INCLUDE ZMCAED_IDOC_WORKBENCH_SUB.

*&---------------------------------------------------------------------*

*& Module SAVE_OK INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE SAVE_OK INPUT. "#EC *

SAVE_OK = OK_CODE.

CLEAR OK_CODE.

ENDMODULE. " SAVE_OK INPUT

TABLES: USR02,WBHK,E1EDK02.

SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-020.

SELECT-OPTIONS: SO_CREA6 FOR WBHK-AEZEIT,

SO_CRON6 FOR EKKO-AEDAT,

SO_CRE6 FOR WBHK-AEZEIT,

SO_CRO6 FOR EKKO-AEDAT.

SELECTION-SCREEN END OF BLOCK B2.

SELECTION-SCREEN END OF SCREEN 200.

*&---------------------------------------------------------------------*

*& Module USER_COMMAND_0200 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

*&---------------------------------------------------------------------*

*& Module STATUS_100 OUTPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE STATUS_100 OUTPUT. "#EC *

SET TITLEBAR 'IDOC Inbound 945 Search Menu '. "#EC *

ENDMODULE. " STATUS_100 OUTPUT

*&---------------------------------------------------------------------*

*& Module STATUS_1000 OUTPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE STATUS_1000 OUTPUT. "#EC *

SET PF-STATUS 'MAIN1'.

SET TITLEBAR 'IDOC WORKBENCH'. "#EC *

ENDMODULE. " STATUS_1000 OUTPUT

*&---------------------------------------------------------------------*

*& Module CANCEL INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE CANCEL INPUT. "#EC *

LEAVE PROGRAM.

ENDMODULE. " CANCEL INPUT

*&---------------------------------------------------------------------*

*& Module STATUS_1001 OUTPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE STATUS_1001 OUTPUT. "#EC *

SET PF-STATUS 'MAIN1'.

* SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_1001 OUTPUT

*&---------------------------------------------------------------------*

*& Form READ_DATA_945

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

FORM READ_DATA_945 .

DATA :LV_F(30) TYPE C,

LV_F1(45) TYPE C,

LV_F2(45) TYPE C,

LV_F3(45) TYPE C,

LV_F4(45) TYPE C,

LV_STRING TYPE STRING.

CONSTANTS : LC_MESST(6) TYPE C VALUE 'CREMAS'.

LV_F = 'MESTYP EQ LC_MESST'.

IF SO_CT1 IS NOT INITIAL AND SO_CT2 IS INITIAL.

LV_F1 = ' AND CRETIM EQ SO_CT1 '.

ENDIF.

IF SO_CT1 IS NOT INITIAL AND SO_CT2 IS NOT INITIAL.

LV_F1 = ' AND CRETIM BETWEEN SO_CT1 AND SO_CT2 '.

ENDIF.

IF SO_CR1 IS NOT INITIAL AND SO_CR2 IS INITIAL.

LV_F2 = ' AND CREDAT EQ SO_CR1 '.

ENDIF.

IF SO_CR1 IS NOT INITIAL AND SO_CR2 IS NOT INITIAL.

LV_F2 = ' AND CREDAT BETWEEN SO_CR1 AND SO_CR2 '.

ENDIF.

IF SO_CHT1 IS NOT INITIAL AND SO_CHT2 IS INITIAL.

LV_F3 = ' AND UPDTIM EQ SO_CHT1'.

ENDIF.

IF SO_CHT1 IS NOT INITIAL AND SO_CHT2 IS NOT INITIAL.

LV_F3 = ' AND UPDTIM BETWEEN SO_CHT1 AND SO_CHT2'.

ENDIF.

IF SO_CHD1 IS NOT INITIAL AND SO_CHD2 IS INITIAL.

LV_F4 = ' AND UPDDAT EQ SO_CHD1 '.

ENDIF.

IF SO_CHD1 IS NOT INITIAL AND SO_CHD2 IS NOT INITIAL.

LV_F4 = ' AND UPDDAT BETWEEN SO_CHD1 AND SO_CHD2 '.

ENDIF.

CONCATENATE LV_F LV_F1 LV_F2 LV_F3 LV_F4 ' .' INTO LV_STRING.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_94 WHERE (LV_STRING).

DATA : LV_DESC TYPE TEDS2-DESCRP,

LV_DOCTYP TYPE EDIDC-DOCTYP.

LOOP AT TB_94 INTO WA_94.

SELECT DESCRP FROM TEDS2 INTO LV_DESC WHERE STATUS = WA_94-STATUS AND LANGUA = 'EN'.

IF sy-subrc eq 0.

wa_945-docnum = wa_94-docnum.

wa_945-direct = wa_94-direct.

wa_945-status = wa_94-status.

wa_945-DESCRP = lv_desc.

wa_945-senprn = wa_94-senprn.

wa_945-recprn = wa_94-recprn.

wa_945-rcvpor = wa_94-rcvpor.

WA_945-IDOCTP = WA_94-IDOCTP.

wa_945-mestyp = wa_94-mestyp.

APPEND wa_945 to tb_945.

ENDIF.

ENDSELECT.

ENDLOOP.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

DOCTYP

MESTYP

FROM EDIDC INTO TABLE TB_9451 where MESTYP EQ LC_MESST.

ENDFORM. " READ_DATA_945

*&---------------------------------------------

*&---------------------------------------------------------------------*

*& Module FILL_THE_VALUES OUTPUT

*&---------------------------------------------------------------------*

MODULE FILL_THE_VALUES OUTPUT. "#EC *

so_crea6[] = so_crea6[].

ENDMODULE. " FILL_THE_VALUES OUTPUT

*&---------------------------------------------------------------------*

*& Module STATUS_1008 OUTPUT

*&---------------------------------------------------------------------*

MODULE STATUS_1008 OUTPUT.

SET PF-STATUS 'MAIN1'.

* SET TITLEBAR 'XXX'.

ENDMODULE. " STATUS_1008 OUTPUT

*&---------------------------------------------------------------------*

*& Module USER_COMMAND_1008 INPUT

*&---------------------------------------------------------------------*

MODULE USER_COMMAND_1008 INPUT.

CASE sy-ucomm.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'CLEA'.

CLEAR:

SO_CT1,SO_CT2,SO_CR1,SO_CR2,SO_CHT1,SO_CHT2,SO_CHD1,SO_CHD2,

SO_VBELN,SO_BSTNR,SO_WERKS,SO_PARTNER_AG,SO_PARTNER_ID,SO_NTANF,SO_MATNR.

WHEN 'SEAR'.

CLEAR : tb_94 ,tb_945.

PERFORM read_data_945.

* Delivery Number Validations

IF so_vbeln IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE

TB_SEGMENT_LIST FOR ALL ENTRIES IN TB_945

WHERE DOCNUM = TB_945-DOCNUM and SEGNAM = 'E1EDL20'.

loop at tb_segment_list into wa_segment_list.

wa_deldata-docnum = wa_segment_list-docnum.

wa_deldata-vbeln = wa_segment_list-sdata+0(18).

append wa_deldata to tb_deldata.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_DELDATA INTO WA_DELDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

IF NOT so_vbeln eq wa_deldata-vbeln .

delete TABLE tb_945 from wa_945.

delete TABLE TB_DELDATA from WA_DELDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

clear : tb_segment_list,tb_deldata,So_vbeln.

* Customer PO Validated data

IF SO_BSTNR IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM and SEGNAM = 'E1EDL41'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(3) = '001'.

wa_deldata-docnum = wa_segment_list-docnum.

WA_DELDATA-bstnr = WA_SEGMENT_LIST-SDATA+3(35).

append wa_deldata to tb_deldata.

endif.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_DELDATA INTO WA_DELDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

TRANSLATE wa_deldata-bstnr to UPPER CASE. "#EC SYNTCHAR

IF NOT so_bstnr eq wa_deldata-bstnr.

delete TABLE tb_945 from wa_945.

delete TABLE TB_DELDATA from WA_DELDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

clear : tb_segment_list,tb_deldata,SO_BSTNR.

* Plant Validated data

IF SO_WERKS IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDL24'.

Loop at tb_segment_list into wa_segment_list.

wa_deldata-docnum = wa_segment_list-docnum.

WA_DELDATA-WERKS = WA_SEGMENT_LIST-SDATA+136(04).

append wa_deldata to tb_deldata.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_DELDATA INTO WA_DELDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

IF NOT so_werks eq wa_deldata-werks.

delete TABLE tb_945 from wa_945.

delete TABLE TB_DELDATA from WA_DELDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

clear : tb_segment_list,tb_deldata,SO_WERKS.

* Ship - To validated data

IF SO_PARTNER_AG IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1ADRM1'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(2) = 'AG'.

wa_deldata-docnum = wa_segment_list-docnum.

WA_DELDATA-SHIP = WA_SEGMENT_LIST-SDATA+4(17).

append wa_deldata to tb_deldata.

ENDIF .

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_DELDATA INTO WA_DELDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

IF NOT SO_PARTNER_AG eq WA_DELDATA-SHIP.

delete TABLE tb_945 from wa_945.

delete TABLE TB_DELDATA from WA_DELDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

* Sold -To validated data

clear : tb_segment_list,tb_deldata, SO_PARTNER_AG.

IF SO_PARTNER_ID IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1ADRM1'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(2) = 'WE'.

wa_deldata-docnum = wa_segment_list-docnum.

WA_DELDATA-SOLD = WA_SEGMENT_LIST-SDATA+4(17).

append wa_deldata to tb_deldata.

endif.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_DELDATA INTO WA_DELDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

IF NOT SO_PARTNER_ID eq WA_DELDATA-SOLD.

delete TABLE tb_945 from wa_945.

delete TABLE TB_DELDATA from WA_DELDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

* Goods Issue data validate data

clear : tb_segment_list,tb_deldata,SO_PARTNER_ID.

IF SO_NTANF IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDT13'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(3) = '006'.

wa_deldata-docnum = wa_segment_list-docnum.

WA_DELDATA-GOODI = WA_SEGMENT_LIST-SDATA+27(08).

append wa_deldata to tb_deldata.

endif.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_DELDATA INTO WA_DELDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

IF NOT SO_NTANF eq WA_DELDATA-GOODI.

delete TABLE tb_945 from wa_945.

delete TABLE TB_DELDATA from WA_DELDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

* Material Validate

clear : tb_segment_list,tb_deldata,SO_NTANF.

IF SO_MATNR IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDL24'.

Loop at tb_segment_list into wa_segment_list.

wa_deldata-docnum = wa_segment_list-docnum.

WA_DELDATA-MATNR = WA_SEGMENT_LIST-SDATA+06(24).

append wa_deldata to tb_deldata.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_DELDATA INTO WA_DELDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

IF NOT SO_MATNR eq WA_DELDATA-MATNR .

delete TABLE tb_945 from wa_945.

delete TABLE TB_DELDATA from WA_DELDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

*

CLEAR : TB_SEGMENT_LIST,SO_MATNR ,tb_deldata.

* ENDIF.

CALL SCREEN 1009.

WHEN 'CANC'.

LEAVE PROGRAM.

WHEN 'EXIT'.

LEAVE TO SCREEN 0 .

ENDCASE.

ENDMODULE. " USER_COMMAND_1008 INPUT

*&---------------------------------------------------------------------*

*& Module PROCESS_VALUE INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE PROCESS_VALUE INPUT. "#EC *

DATA :LV_F(30) TYPE C,

lv_f1(45) TYPE c,

LV_F2(45) TYPE C,

LV_F3(45) TYPE C,

LV_F4(45) TYPE C,

lv_string TYPE string.

CONSTANTS : lc_messt(6) TYPE c VALUE 'SHPCON'.

lv_f = 'MESTYP EQ LC_MESST'.

if so_ct1 is not INITIAL and so_ct2 is INITIAL.

lv_f1 = ' AND CRETIM EQ SO_CT1 '.

endif.

if so_ct1 is not INITIAL and so_ct2 is NOT INITIAL.

lv_f1 = ' AND CRETIM BETWEEN SO_CT1 AND SO_CT2 '.

endif.

IF SO_CR1 is not initial and so_cr2 is INITIAL.

LV_F2 = ' AND CREDAT EQ SO_CR1 '.

ENDIF.

IF SO_CR1 is not initial and so_cr2 is Not INITIAL.

LV_F2 = ' AND CREDAT BETWEEN SO_CR1 AND SO_CR2 '.

ENDIF.

if so_cht1 is not INITIAL and so_cht2 is INITIAL.

lv_f3 = ' AND UPDTIM EQ SO_CHT1'.

endif.

if so_cht1 is not INITIAL and so_cht2 is NOT INITIAL.

lv_f3 = ' AND UPDTIM BETWEEN SO_CHT1 AND SO_CHT2'.

endif.

IF SO_CHD1 is not initial and so_cHD2 is INITIAL.

LV_F4 = ' AND UPDDAT EQ SO_CHD1 '.

ENDIF.

IF SO_CHD1 is not initial and so_cHD2 is Not INITIAL.

LV_F4 = ' AND UPDDAT BETWEEN SO_CHD1 AND SO_CHD2 '.

ENDIF.

CONCATENATE lv_f lv_f1 lv_f2 lv_f3 lv_f4 INTO lv_string.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

DOCTYP

MESTYP

FROM EDIDC INTO TABLE TB_945 WHERE (lv_string).

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN TB_945

WHERE DOCNUM = TB_945-DOCNUM.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST .

IF SY-SUBRC eq 0 .

if wa_segment_list-segnum = '000001' AND wa_segment_list-SEGNAM = 'E1EDL20'.

WA_DELDATA-DOCNUM = WA_SEGMENT_LIST-DOCNUM.

WA_DELDATA-VBELN = WA_SEGMENT_LIST-SDATA+0(10).

ELSEIF WA_SEGMENT_LIST-SEGNUM = '000006' AND WA_SEGMENT_LIST-SEGNAM = 'E1ADRM1'.

WA_DELDATA-SOLD = WA_SEGMENT_LIST-SDATA+4(10).

elseif wa_segment_list-segnum = '000007' AND wa_segment_list-SEGNAM = 'E1ADRM1'.

WA_DELDATA-SHIP = WA_SEGMENT_LIST-SDATA+4(10).

ELSEIF WA_SEGMENT_LIST-SEGNUM = '000010' AND WA_SEGMENT_LIST-SEGNAM = 'E1EDT13'.

WA_DELDATA-GOODI = WA_SEGMENT_LIST-SDATA+27(08).

elseif wa_segment_list-segnum = '000016' AND wa_segment_list-SEGNAM = 'E1EDL24'.

WA_DELDATA-MATNR = WA_SEGMENT_LIST-SDATA+06(24).

WA_DELDATA-WERKS = WA_SEGMENT_LIST-SDATA+136(04).

ELSEIF WA_SEGMENT_LIST-SEGNUM = '000022' AND WA_SEGMENT_LIST-SEGNAM = 'E1EDL41'.

WA_DELDATA-bstnr = WA_SEGMENT_LIST-SDATA+3(22).

APPEND WA_DELDATA TO TB_DELDATA .

ENDIF.

endif.

ENDLOOP.

sort tb_deldata by docnum vbeln.

DELETE ADJACENT DUPLICATES FROM tb_deldata.

ENDMODULE. " PROCESS_VALUE INPUT

*&---------------------------------------------------------------------*

*& Module INTIAL_VALUES OUTPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE INTIAL_VALUES OUTPUT. "#EC *

IF SO_CR1 LE SO_CR2.

MESSAGE E001.

ENDIF.

ENDMODULE. " INTIAL_VALUES OUTPUT

*&---------------------------------------------------------------------*

*& Module INTIAL_VALUES INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE INTIAL_VALUES INPUT.

IF SO_CT1 is not initial and SO_CT2 is not INITIAL.

IF SO_CT2 LE SO_CT1.

MESSAGE w001.

ENDIF.

endif.

IF SO_CR1 is not initial and so_cr2 is not INITIAL.

IF SO_CR2 LE SO_CR1.

MESSAGE w001.

ENDIF.

endif.

IF SO_CHT1 is not initial and SO_CHT2 is not INITIAL.

IF SO_CHT2 LE SO_CHT1.

MESSAGE w001.

ENDIF.

endif.

IF SO_CHD1 is not initial and so_chd2 is not INITIAL.

IF SO_CHD2 LE SO_CHD1.

MESSAGE w001.

ENDIF.

endif.

ENDMODULE. " INTIAL_VALUES INPUT

CONTROLS: TC_101 TYPE TABLEVIEW USING SCREEN 1009.

*----------------------------------------------------------------------*

* MODULE TC_101_CHANGE_TC_ATTR OUTPUT

*----------------------------------------------------------------------*

MODULE TC_101_CHANGE_TC_ATTR OUTPUT.

DESCRIBE TABLE TB_945 LINES TC_101-lines.

CLEAR: v_indx.

ENDMODULE. "TC_101_CHANGE_TC_ATTR OUTPUT

*&---------------------------------------------------------------------*

*& Module USER_COMMAND_1009 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE USER_COMMAND_1009 INPUT.

CASE sy-ucomm.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'EXIT'.

LEAVE TO SCREEN 0 .

WHEN 'CANC'.

LEAVE PROGRAM.

when 'DISP'.

PERFORM FM_GET_DATA.

when 'CHAN' .

PERFORM FM_GET_DATA.

WHEN 'REPR'.

PERFORM FM_GET_DATA1.

ENDCASE.

ENDMODULE. " USER_COMMAND_1009 INPUT

*&---------------------------------------------------------------------*

*& Module STATUS_1009 OUTPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE STATUS_1009 OUTPUT.

SET PF-STATUS 'MAIN2'.

* SET TITLEBAR 'XXX'.

ENDMODULE. " STATUS_1009 OUTPUT

*&---------------------------------------------------------------------*

*& Form FM_GET_DATA

*&---------------------------------------------------------------------*

FORM FM_GET_DATA .

* clear v_indx.

GET CURSOR LINE v_indx.

READ TABLE TB_945 INTO WA_945 INDEX v_indx.

* v_indx.

*if sy-subrc = 0.

Data : LV_credat type edidc-credat .

SELECT single credat into lv_credat from edidc where docnum eq wa_945-docnum.

data: begin of record,

* data element:

LOW_001(008),

* data element:

HIGH_002(008),

* data element:

LOW_003(010),

* data element:

HIGH_004(010),

* data element:

LOW_005(008),

* data element:

HIGH_006(008),

* data element:

LOW_007(016),

* data element:

LOW_008(030),

end of record.

perform bdc_dynpro using 'RSEIDOC2' '1000'.

perform bdc_field using 'BDC_CURSOR'

'DOCNUM-LOW'.

perform bdc_field using 'CRETIM-LOW'

record-LOW_001.

perform bdc_field using 'CRETIM-HIGH'

'24:00:00'.

* record-HIGH_002.

perform bdc_field using 'CREDAT-LOW'

record-LOW_003.

perform bdc_field using 'CREDAT-HIGH'

record-HIGH_004.

perform bdc_field using 'UPDTIM-LOW'

record-LOW_005.

perform bdc_field using 'UPDTIM-HIGH'

'24:00:00'.

* record-HIGH_006.

perform bdc_field using 'DOCNUM-LOW'

wa_945-docnum.

perform bdc_field using 'IDOCTP-LOW'

record-LOW_008.

perform bdc_transaction using 'WE02' .

* CLEAR : v_indx, wa_945 .

free BDCDATA.

ENDFORM. " FM_GET_DATA

*&---------------------------------------------------------------------*

*& Form FM_GET_DATA1

*&---------------------------------------------------------------------*

FORM FM_GET_DATA1 .

data : lv_credat TYPE edidc-credat.

GET CURSOR LINE v_indx.

READ TABLE TB_945 INTO WA_945 INDEX v_indx.

* if sy-subrc = 0.

data: begin of record,

* data element:

LOW_001(016),

* data element:

LOW_002(008),

* data element:

HIGH_003(008),

* data element:

LOW_004(010),

* data element:

HIGH_005(010),

* data element:

LOW_006(008),

* data element:

HIGH_007(008),

end of record.

SELECT single UPDDAT from edidc into lv_credat where docnum eq wa_945-docnum.

* CLEAR BDCDATA.

perform bdc_dynpro1 using 'RBDMON00' '1100'.

perform bdc_field1 using 'BDC_CURSOR'

'SX_UPDDA-HIGH'.

perform bdc_field1 using 'SX_DOCNU-LOW'

wa_945-docnum.

* record-LOW_001.

perform bdc_field1 using 'SX_CRETI-LOW'

'00:00:00'.

* record-LOW_002.

perform bdc_field1 using 'SX_CRETI-HIGH'

'00:00:00'.

* record-HIGH_003.

perform bdc_field1 using 'SX_UPDDA-LOW'

record-LOW_004.

perform bdc_field1 using 'SX_UPDDA-HIGH'

record-HIGH_005.

perform bdc_field1 using 'SX_UPDTI-LOW'

'00:00:00'.

* record-LOW_006.

perform bdc_field1 using 'SX_UPDTI-HIGH'

'00:00:00'.

*

perform bdc_transaction1 using 'BD87'.

FREE BDCDATA1.

ENDFORM. " FM_GET_DATA1

*----------------------------------------------------------------------*

FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR BDCDATA.

BDCDATA-PROGRAM = PROGRAM.

BDCDATA-DYNPRO = DYNPRO.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA.

ENDFORM. "BDC_DYNPRO

*----------------------------------------------------------------------*

* Insert field *

*----------------------------------------------------------------------*

FORM BDC_FIELD USING FNAM FVAL.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA. "#EC .., bzw

ENDFORM. "BDC_FIELD

*&---------------------------------------------------------------------*

*& Form BDC_TRANSACTION

FORM BDC_TRANSACTION USING TCODE.

DATA: L_MSTRING(480).

DATA: L_SUBRC LIKE SY-SUBRC.

CALL TRANSACTION TCODE USING BDCDATA.

ENDFORM. "BDC_TRANSACTION

*&---------------------------------------------------------------------*

*& Module USER_COMMAND_1010 INPUT

*&---------------------------------------------------------------------*

MODULE USER_COMMAND_1010 INPUT.

CASE sy-ucomm.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'CLEA'.

CLEAR:

SO_CT1,SO_CT2,SO_CR1,SO_CR2,SO_CHT1,SO_CHT2,SO_CHD1,SO_CHD2,

SO_CUSTO,SO_SOLD1,SO_SHIP1,SO_PLAN1,SO_SAPM,SO_CUTOM,SO_VBELN1.

WHEN 'SEAR'.

*

PERFORM read_data_850.

* Customer PO Validations

IF so_custo IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN TB_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDK02'.

loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(3) EQ '001'.

wa_orddata-docnum = wa_segment_list-docnum.

wa_orddata-belnr = wa_segment_list-sdata+3(35).

append wa_orddata to tb_orddata.

ENDIF.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_ordDATA INTO WA_ORDDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

TRANSLATE wa_ORDdata-belnr to UPPER CASE. "#EC SYNTCHAR

IF NOT so_custo eq wa_orddata-belnr .

delete TABLE tb_945 from wa_945.

delete TABLE TB_ORDDATA from WA_ORDDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

clear : tb_segment_list,tb_orddata,so_custo.

* Sold-To

IF so_sold1 IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDKA1'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(2) EQ 'AG'.

wa_orddata-docnum = wa_segment_list-docnum.

WA_ORDDATA-SOLD = WA_SEGMENT_LIST-SDATA+3(17).

append wa_orddata to tb_orddata.

endif.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_ORDDATA INTO WA_ORDDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

IF NOT so_sold1 eq wa_ORDDATA-sold.

delete TABLE tb_945 from wa_945.

delete TABLE TB_ORDDATA from WA_ORDDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

clear : tb_segment_list,tb_orddata,so_sold1.

* Ship To

IF so_ship1 IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDKA1'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(2) EQ 'WE'.

wa_orddata-docnum = wa_segment_list-docnum.

WA_ORDDATA-ship = WA_SEGMENT_LIST-SDATA+3(17).

append wa_orddata to tb_orddata.

endif.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_ORDDATA INTO WA_ORDDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

* TRANSLATE wa_ORDDATA-bstnr to UPPER CASE.

IF NOT so_ship1 eq wa_ORDDATA-ship.

delete TABLE tb_945 from wa_945.

delete TABLE TB_ORDDATA from WA_ORDDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

clear : tb_segment_list,tb_orddata, so_ship1.

*Plant

IF SO_PLAN1 IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDP01'.

Loop at tb_segment_list into wa_segment_list.

wa_orddata-docnum = wa_segment_list-docnum.

WA_ORDDATA-plan = WA_SEGMENT_LIST-SDATA+311(04).

append wa_orddata to tb_orddata.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_ORDDATA INTO WA_ORDDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

IF NOT so_plan1 eq wa_ORDDATA-plan.

delete TABLE tb_945 from wa_945.

delete TABLE TB_ORDDATA from WA_ORDDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

clear : tb_segment_list,tb_orddata,SO_PLAN1 .

* SAP Material

IF so_sapm IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDP19'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(3) = '002'.

wa_orddata-docnum = wa_segment_list-docnum.

WA_ORDDATA-sapm = WA_SEGMENT_LIST-SDATA+3(35).

append wa_orddata to tb_orddata.

endif.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_ORDDATA INTO WA_ORDDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

IF NOT so_sapm eq wa_ORDDATA-sapm.

delete TABLE tb_945 from wa_945.

delete TABLE TB_ORDDATA from WA_ORDDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

clear : tb_segment_list,tb_orddata,so_sapm.

*Customer Material

IF so_cutom IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM and SEGNAM = 'E1EDP19'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(03) = '001'.

wa_orddata-docnum = wa_segment_list-docnum.

WA_ORDDATA-CUSTPO = WA_SEGMENT_LIST-SDATA+3(35).

append wa_orddata to tb_orddata.

ENDIF.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_ORDDATA INTO WA_ORDDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

TRANSLATE wa_ORDDATA-custpo to UPPER CASE. "#EC SYNTCHAR

IF NOT so_cutom eq wa_ORDDATA-custpo.

delete TABLE tb_945 from wa_945.

delete TABLE TB_ORDDATA from WA_ORDDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

clear : tb_segment_list,tb_orddata,so_cutom.

*Sales Order

IF so_vbeln1 IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM and SEGNAM = 'E1EDP19'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(03) = '003'.

wa_orddata-docnum = wa_segment_list-docnum.

WA_ORDDATA-SALES = WA_SEGMENT_LIST-SDATA+3(35).

append wa_orddata to tb_orddata.

ENDIF.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_ORDDATA INTO WA_ORDDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

IF NOT so_VBELN1 eq wa_ORDDATA-sales.

delete TABLE tb_945 from wa_945.

delete TABLE TB_ORDDATA from WA_ORDDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

clear : tb_segment_list,tb_orddata,so_vbeln1.

CLEAR : TB_SEGMENT_LIST.

* ENDIF.

CALL SCREEN 1009.

WHEN 'CANC'.

LEAVE PROGRAM.

WHEN 'EXIT'.

LEAVE TO SCREEN 0 .

ENDCASE.

ENDMODULE. " USER_COMMAND_1010 INPUT

*&---------------------------------------------------------------------*

*& Form READ_DATA_850

*&---------------------------------------------------------------------*

FORM READ_DATA_850 .

DATA :LV_F(80) TYPE C,

lv_f1(45) TYPE c,

LV_F2(45) TYPE C,

LV_F3(45) TYPE C,

LV_F4(45) TYPE C,

lv_string TYPE string.

clear : tb_945.

CONSTANTS : lc_messt1(6) TYPE c VALUE 'ORDERS',

lc_messt2(1) TYPE c VALUE '2'.

lv_f = 'MESTYP EQ LC_MESST1 AND DIRECT EQ LC_MESST2 '. "#EC NOTEXT

if so_ct1 is not INITIAL and so_ct2 is INITIAL.

lv_f1 = ' AND CRETIM EQ SO_CT1 '.

endif.

if so_ct1 is not INITIAL and so_ct2 is NOT INITIAL.

lv_f1 = ' AND CRETIM BETWEEN SO_CT1 AND SO_CT2 '.

endif.

IF SO_CR1 is not initial and so_cr2 is INITIAL.

LV_F2 = ' AND CREDAT EQ SO_CR1 '.

ENDIF.

IF SO_CR1 is not initial and so_cr2 is Not INITIAL.

LV_F2 = ' AND CREDAT BETWEEN SO_CR1 AND SO_CR2 '.

ENDIF.

if so_cht1 is not INITIAL and so_cht2 is INITIAL.

lv_f3 = ' AND UPDTIM EQ SO_CHT1'.

endif.

if so_cht1 is not INITIAL and so_cht2 is NOT INITIAL.

lv_f3 = ' AND UPDTIM BETWEEN SO_CHT1 AND SO_CHT2'.

endif.

IF SO_CHD1 is not initial and so_cHD2 is INITIAL.

LV_F4 = ' AND UPDDAT EQ SO_CHD1 '.

ENDIF.

IF SO_CHD1 is not initial and so_cHD2 is Not INITIAL.

LV_F4 = ' AND UPDDAT BETWEEN SO_CHD1 AND SO_CHD2 '.

ENDIF.

CONCATENATE lv_f lv_f1 lv_f2 lv_f3 lv_f4 ' .' INTO lv_string.

clear : tb_94, tb_945.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_94 WHERE (lv_string).

data : lv_desc TYPE teds2-descrp,

LV_DOCTYP TYPE EDIDC-DOCTYP .

loop at tb_94 INTO wa_94.

SELECT descrp from teds2 into lv_desc where STATUS = wa_94-status and LANGUA = 'EN'.

IF SY-SUBRC EQ 0.

WA_945-DOCNUM = WA_94-DOCNUM.

WA_945-DIRECT = WA_94-DIRECT.

WA_945-STATUS = WA_94-STATUS.

WA_945-DESCRP = LV_DESC.

WA_945-SENPRN = WA_94-SENPRN.

WA_945-RECPRN = WA_94-RECPRN.

WA_945-RCVPOR = WA_94-RCVPOR.

WA_945-IDOCTP = WA_94-IDOCTP.

WA_945-MESTYP = WA_94-MESTYP.

APPEND WA_945 TO TB_945.

ENDIF.

ENDSELECT.

ENDLOOP.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

DOCTYP

MESTYP

FROM EDIDC INTO TABLE TB_9451 WHERE MESTYP EQ LC_MESST.

ENDFORM. " READ_DATA_850

*&---------------------------------------------------------------------*

*& Module STATUS_1010 OUTPUT

*&---------------------------------------------------------------------*

MODULE STATUS_1010 OUTPUT.

SET PF-STATUS 'MAIN1'.

* SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_1010 OUTPUT

*&---------------------------------------------------------------------*

*& Module STATUS_1011 OUTPUT

*&---------------------------------------------------------------------*

MODULE STATUS_1011 OUTPUT.

SET PF-STATUS 'MAIN1'.

* SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_1011 OUTPUT

*&---------------------------------------------------------------------*

*& Module USER_COMMAND_1011 INPUT

*&---------------------------------------------------------------------*

MODULE USER_COMMAND_1011 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'CLEA'.

CLEAR:

SO_CT1,SO_CT2,SO_CR1,SO_CR2,SO_CHT1,SO_CHT2,SO_CHD1,SO_CHD2,

SO_CUSTO,SO_SOLD1,SO_SHIP1,SO_PLAN1,SO_SAPM,SO_CUTOM,SO_VBELN1.

WHEN 'SEAR'.

PERFORM READ_DATA_810.

* PO NUMBER

IF SO_PO IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN TB_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDP02'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(3) EQ '013'.

WA_INVDATA-DOCNUM = WA_SEGMENT_LIST-DOCNUM.

WA_INVDATA-BELNR = WA_SEGMENT_LIST-SDATA+3(35).

APPEND WA_INVDATA TO TB_INVDATA.

ENDIF.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_INVDATA INTO WA_INVDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC EQ 0.

TRANSLATE WA_INVDATA-BELNR TO UPPER CASE. "#EC SYNTCHAR

IF NOT SO_PO EQ WA_INVDATA-BELNR .

DELETE TABLE TB_945 FROM WA_945.

DELETE TABLE TB_INVDATA FROM WA_INVDATA.

ENDIF.

ELSE.

DELETE TABLE TB_945 FROM WA_945.

ENDIF.

ENDLOOP.

ENDIF.

CLEAR : TB_SEGMENT_LIST,TB_INVDATA,SO_PO.

* Vendor

IF SO_VEN IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDKA1'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(2) EQ 'AG'.

WA_INVDATA-DOCNUM = WA_SEGMENT_LIST-DOCNUM.

WA_INVDATA-VEN = WA_SEGMENT_LIST-SDATA+3(17).

APPEND WA_INVDATA TO TB_INVDATA.

ENDIF.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_INVDATA INTO WA_INVDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC EQ 0.

* TRANSLATE wa_ORDDATA-bstnr to UPPER CASE.

IF NOT SO_VEN EQ WA_INVDATA-VEN.

DELETE TABLE TB_945 FROM WA_945.

DELETE TABLE TB_INVDATA FROM WA_INVDATA.

ENDIF.

ELSE.

DELETE TABLE TB_945 FROM WA_945.

ENDIF.

ENDLOOP.

ENDIF.

CLEAR : TB_SEGMENT_LIST,TB_INVDATA,SO_VEN.

* Vendor invoice

IF SO_VENIN IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDK02'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(3) EQ '009'.

WA_INVDATA-DOCNUM = WA_SEGMENT_LIST-DOCNUM.

WA_INVDATA-VENIN = WA_SEGMENT_LIST-SDATA+3(35).

APPEND WA_INVDATA TO TB_INVDATA.

ENDIF.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_INVDATA INTO WA_INVDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC EQ 0.

* TRANSLATE wa_ORDDATA-bstnr to UPPER CASE.

IF NOT SO_VENIN EQ WA_INVDATA-VENIN.

DELETE TABLE TB_945 FROM WA_945.

DELETE TABLE TB_INVDATA FROM WA_INVDATA.

ENDIF.

ELSE.

DELETE TABLE TB_945 FROM WA_945.

ENDIF.

ENDLOOP.

ENDIF.

CLEAR : TB_SEGMENT_LIST,TB_INVDATA,SO_VENIN.

*Plant

IF SO_SAPVEN IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDK02'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(3) EQ '002'.

WA_INVDATA-DOCNUM = WA_SEGMENT_LIST-DOCNUM.

WA_INVDATA-SAPVEN = WA_SEGMENT_LIST-SDATA+3(35).

APPEND WA_INVDATA TO TB_INVDATA.

ENDIF.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_INVDATA INTO WA_INVDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC EQ 0.

* TRANSLATE wa_ORDDATA-bstnr to UPPER CASE.

IF NOT SO_SAPVEN EQ WA_INVDATA-SAPVEN.

DELETE TABLE TB_945 FROM WA_945.

DELETE TABLE TB_INVDATA FROM WA_INVDATA.

ENDIF.

ELSE.

DELETE TABLE TB_945 FROM WA_945.

ENDIF.

ENDLOOP.

ENDIF.

CLEAR : TB_SEGMENT_LIST,TB_INVDATA,SO_SAPVEN.

CLEAR : TB_SEGMENT_LIST.

* ENDIF.

CALL SCREEN 1009.

WHEN 'CANC'.

LEAVE PROGRAM.

WHEN 'EXIT'.

LEAVE TO SCREEN 0 .

ENDCASE.

ENDMODULE. " USER_COMMAND_1011 INPUT

*&---------------------------------------------------------------------*

*& Form READ_DATA_810

*&---------------------------------------------------------------------*

FORM READ_DATA_810 .

DATA :LV_F(80) TYPE C,

LV_F1(45) TYPE C,

LV_F2(45) TYPE C,

LV_F3(45) TYPE C,

LV_F4(45) TYPE C,

LV_STRING TYPE STRING.

CLEAR : TB_945.

CONSTANTS : LC_MESST1(6) TYPE C VALUE 'INVOIC',

LC_MESST2(1) TYPE C VALUE '2'.

LV_F = 'MESTYP EQ LC_MESST1 and DIRECT EQ lc_messt2 '. "#EC NOTEXT

IF SO_CT1 IS NOT INITIAL AND SO_CT2 IS INITIAL.

LV_F1 = ' AND CRETIM EQ SO_CT1 '.

ENDIF.

IF SO_CT1 IS NOT INITIAL AND SO_CT2 IS NOT INITIAL.

LV_F1 = ' AND CRETIM BETWEEN SO_CT1 AND SO_CT2 '.

ENDIF.

IF SO_CR1 IS NOT INITIAL AND SO_CR2 IS INITIAL.

LV_F2 = ' AND CREDAT EQ SO_CR1 '.

ENDIF.

IF SO_CR1 IS NOT INITIAL AND SO_CR2 IS NOT INITIAL.

LV_F2 = ' AND CREDAT BETWEEN SO_CR1 AND SO_CR2 '.

ENDIF.

IF SO_CHT1 IS NOT INITIAL AND SO_CHT2 IS INITIAL.

LV_F3 = ' AND UPDTIM EQ SO_CHT1'.

ENDIF.

IF SO_CHT1 IS NOT INITIAL AND SO_CHT2 IS NOT INITIAL.

LV_F3 = ' AND UPDTIM BETWEEN SO_CHT1 AND SO_CHT2'.

ENDIF.

IF SO_CHD1 IS NOT INITIAL AND SO_CHD2 IS INITIAL.

LV_F4 = ' AND UPDDAT EQ SO_CHD1 '.

ENDIF.

IF SO_CHD1 IS NOT INITIAL AND SO_CHD2 IS NOT INITIAL.

LV_F4 = ' AND UPDDAT BETWEEN SO_CHD1 AND SO_CHD2 '.

ENDIF.

CONCATENATE LV_F LV_F1 LV_F2 LV_F3 LV_F4 ' .' INTO LV_STRING.

CLEAR : TB_94, TB_945.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_94 WHERE (LV_STRING).

DATA : LV_DESC TYPE TEDS2-DESCRP,

LV_DOCTYP TYPE EDIDC-DOCTYP .

LOOP AT TB_94 INTO WA_94.

SELECT DESCRP FROM TEDS2 INTO LV_DESC WHERE STATUS = WA_94-STATUS AND LANGUA = 'EN'.

IF sy-subrc eq 0.

wa_945-docnum = wa_94-docnum.

wa_945-direct = wa_94-direct.

wa_945-status = wa_94-status.

wa_945-DESCRP = lv_desc.

wa_945-senprn = wa_94-senprn.

wa_945-recprn = wa_94-recprn.

wa_945-rcvpor = wa_94-rcvpor.

WA_945-IDOCTP = WA_94-IDOCTP.

wa_945-mestyp = wa_94-mestyp.

APPEND wa_945 to tb_945.

ENDIF.

ENDSELECT.

ENDLOOP.

ENDFORM. " READ_DATA_810

*&---------------------------------------------------------------------*

*& Module STATUS_1012 OUTPUT

*&---------------------------------------------------------------------*

MODULE STATUS_1012 OUTPUT.

SET PF-STATUS 'MAIN1'.

* SET TITLEBAR 'XXX'.

ENDMODULE. " STATUS_1012 OUTPUT

*&---------------------------------------------------------------------*

*& Module USER_COMMAND_1012 INPUT

MODULE USER_COMMAND_1012 INPUT.

CASE sy-ucomm.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'CLEA'.

CLEAR:

SO_CT1,SO_CT2,SO_CR1,SO_CR2,SO_CHT1,SO_CHT2,SO_CHD1,SO_CHD2,

S0_DELIVERY,SO_BSTNR1,SO_WERKS1,SO_SHIP2 ,SO_SOLD2 ,SO_MATNR2.

WHEN 'SEAR'.

PERFORM read_data_940.

* PO NUMBER

IF S0_DELIVERY IS NOT INITIAL.

clear:tb_deldata,wa_deldata.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN TB_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDL20'.

loop at tb_segment_list into wa_segment_list.

wa_deldata-docnum = wa_segment_list-docnum.

wa_deldata-vbeln = wa_segment_list-sdata+0(10).

append wa_deldata to tb_deldata.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_DELDATA INTO WA_DELDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

IF NOT S0_DELIVERY eq wa_deldata-vbeln .

delete TABLE tb_945 from wa_945.

delete TABLE TB_DELDATA from WA_DELDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

clear : tb_segment_list,tb_deldata,S0_DELIVERY.

* Vendor

IF SO_BSTNR1 IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDL41'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(3) EQ '001'.

wa_DELdata-docnum = wa_segment_list-docnum.

WA_DELDATA-BSTNR = WA_SEGMENT_LIST-SDATA+3(35).

append wa_deldata to tb_deldata.

endif.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_DELDATA INTO WA_DELDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

TRANSLATE wa_DELDATA-bstnr to UPPER CASE. "#EC SYNTCHAR

IF NOT SO_BSTNR1 eq WA_DELDATA-BSTNR.

delete TABLE tb_945 from wa_945.

delete TABLE TB_DELDATA from WA_DELDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

clear : tb_segment_list,tb_deldata,so_bstnr1.

* Vendor invoice

IF SO_WERKS1 IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDL24'.

Loop at tb_segment_list into wa_segment_list.

wa_deldata-docnum = wa_segment_list-docnum.

WA_DELDATA-werks = WA_SEGMENT_LIST-SDATA+136(04).

append wa_deldata to tb_deldata.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_DELDATA INTO WA_DELDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

* TRANSLATE wa_ORDDATA-bstnr to UPPER CASE.

IF NOT SO_WERKS1 eq wa_DELDATA-WERKS.

delete TABLE tb_945 from wa_945.

delete TABLE TB_delDATA from WA_DELDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

clear : tb_segment_list,tb_deldata ,so_werks1..

*Plant

IF SO_SHIP2 IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1ADRM1'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(3) EQ 'AG'.

wa_DELdata-docnum = wa_segment_list-docnum.

WA_DELDATA-SHIP = WA_SEGMENT_LIST-SDATA+4(35).

append wa_deldata to tb_deldata.

endif.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_delDATA INTO WA_DELDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

* TRANSLATE wa_ORDDATA-bstnr to UPPER CASE.

IF NOT so_ship2 eq wa_deldata-ship.

delete TABLE tb_945 from wa_945.

delete TABLE TB_DELDATA from WA_DELDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

CLEAR:so_ship2.

ENDIF.

IF SO_SOLD2 IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1ADRM1'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(3) EQ 'WE'.

wa_deldata-docnum = wa_segment_list-docnum.

WA_DELDATA-SOLD = WA_SEGMENT_LIST-SDATA+4(35).

append wa_deldata to tb_deldata.

endif.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_DELDATA INTO WA_DELDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

* TRANSLATE wa_ORDDATA-bstnr to UPPER CASE.

IF NOT so_sold2 eq wa_deldata-sold.

delete TABLE tb_945 from wa_945.

delete TABLE TB_DELDATA from WA_DELDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

clear : tb_segment_list,tb_deldata,so_sold2.

CLEAR : TB_SEGMENT_LIST.

* ENDIF.

if SO_MATNR2 IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDL24'.

Loop at tb_segment_list into wa_segment_list.

wa_deldata-docnum = wa_segment_list-docnum.

WA_DELDATA-MATNR = WA_SEGMENT_LIST-SDATA+6(18).

append wa_deldata to tb_deldata.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_DELDATA INTO WA_DELDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

TRANSLATE wa_DELDATA-MATNR to UPPER CASE. "#EC SYNTCHAR

IF NOT SO_MATNR2 eq wa_deldata-MATNR.

delete TABLE tb_945 from wa_945.

delete TABLE TB_DELDATA from WA_DELDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

clear : tb_segment_list,tb_deldata,so_matnr2.

CLEAR : TB_SEGMENT_LIST.

* ENDIF.

CALL SCREEN 1009.

WHEN 'CANC'.

LEAVE PROGRAM.

WHEN 'EXIT'.

LEAVE TO SCREEN 0 .

ENDCASE.

ENDMODULE. " USER_COMMAND_1012 INPUT

*&---------------------------------------------------------------------*

*& Form READ_DATA_940

*&---------------------------------------------------------------------*

FORM READ_DATA_940 .

DATA :LV_F(80) TYPE C,

lv_f1(45) TYPE c,

LV_F2(45) TYPE C,

LV_F3(45) TYPE C,

LV_F4(45) TYPE C,

lv_string TYPE string.

clear : tb_945.

CONSTANTS : lc_messt1(6) TYPE c VALUE 'SHPORD',

lc_messt2(1) TYPE c VALUE '1'.

lv_f = 'MESTYP EQ LC_MESST1 AND DIRECT EQ LC_MESST2 '. "#EC NOTEXT

if so_ct1 is not INITIAL and so_ct2 is INITIAL.

lv_f1 = ' AND CRETIM EQ SO_CT1 '.

endif.

if so_ct1 is not INITIAL and so_ct2 is NOT INITIAL.

lv_f1 = ' AND CRETIM BETWEEN SO_CT1 AND SO_CT2 '.

endif.

IF SO_CR1 is not initial and so_cr2 is INITIAL.

LV_F2 = ' AND CREDAT EQ SO_CR1 '.

ENDIF.

IF SO_CR1 is not initial and so_cr2 is Not INITIAL.

LV_F2 = ' AND CREDAT BETWEEN SO_CR1 AND SO_CR2 '.

ENDIF.

if so_cht1 is not INITIAL and so_cht2 is INITIAL.

lv_f3 = ' AND UPDTIM EQ SO_CHT1'.

endif.

if so_cht1 is not INITIAL and so_cht2 is NOT INITIAL.

lv_f3 = ' AND UPDTIM BETWEEN SO_CHT1 AND SO_CHT2'.

endif.

IF SO_CHD1 is not initial and so_cHD2 is INITIAL.

LV_F4 = ' AND UPDDAT EQ SO_CHD1 '.

ENDIF.

IF SO_CHD1 is not initial and so_cHD2 is Not INITIAL.

LV_F4 = ' AND UPDDAT BETWEEN SO_CHD1 AND SO_CHD2 '.

ENDIF.

CONCATENATE lv_f lv_f1 lv_f2 lv_f3 lv_f4 ' .' INTO lv_string.

clear : tb_94, tb_945.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_94 WHERE (lv_string).

data : lv_desc TYPE teds2-descrp,

LV_DOCTYP TYPE EDIDC-DOCTYP .

loop at tb_94 INTO wa_94.

SELECT descrp from teds2 into lv_desc where STATUS = wa_94-status and LANGUA = 'EN'.

IF SY-SUBRC EQ 0.

WA_945-DOCNUM = WA_94-DOCNUM.

WA_945-DIRECT = WA_94-DIRECT.

WA_945-STATUS = WA_94-STATUS.

WA_945-DESCRP = LV_DESC.

WA_945-SENPRN = WA_94-SENPRN.

WA_945-RECPRN = WA_94-RECPRN.

WA_945-RCVPOR = WA_94-RCVPOR.

WA_945-IDOCTP = WA_94-IDOCTP.

WA_945-MESTYP = WA_94-MESTYP.

APPEND WA_945 TO TB_945.

ENDIF.

ENDSELECT.

ENDLOOP.

ENDFORM. " READ_DATA_940

*&---------------------------------------------------------------------*

*& Module STATUS_1013 OUTPUT

*&---------------------------------------------------------------------*

MODULE STATUS_1013 OUTPUT.

SET PF-STATUS 'MAIN1'.

* SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_1013 OUTPUT

*&---------------------------------------------------------------------*

*& Module USER_COMMAND_1013 INPUT

*&---------------------------------------------------------------------*

MODULE USER_COMMAND_1013 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'CLEA'.

CLEAR:

SO_CT1,SO_CT2,SO_CR1,SO_CR2,SO_CHT1,SO_CHT2,SO_CHD1,SO_CHD2,

SO_PARTN3,SO_BELNR3,SO_WERKS3,SO_IDTNR3,SO_BELNR13,SO_ORGID.

WHEN 'SEAR'.

PERFORM READ_DATA_8501.

* PO NUMBER

IF SO_PARTN3 IS NOT INITIAL.

CLEAR:TB_ORDDATA,WA_ORDDATA.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN TB_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDKA1'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(2) = 'LF'.

WA_ORDDATA-DOCNUM = WA_SEGMENT_LIST-DOCNUM.

WA_ORDDATA-SOLD = WA_SEGMENT_LIST-SDATA+3(17).

APPEND WA_ORDDATA TO TB_ORDDATA.

ENDIF.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_ORDDATA INTO WA_ORDDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC EQ 0.

* TRANSLATE wa_invdata-belnr to UPPER CASE.

IF NOT SO_PARTN3 EQ WA_ORDDATA-SOLD .

DELETE TABLE TB_945 FROM WA_945.

DELETE TABLE TB_ORDDATA FROM WA_ORDDATA.

ENDIF.

ELSE.

DELETE TABLE TB_945 FROM WA_945.

ENDIF.

ENDLOOP.

ENDIF.

CLEAR : TB_SEGMENT_LIST,TB_ORDDATA,SO_PARTN3.

* Vendor

IF SO_BELNR3 IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDK01'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

WA_ORDDATA-DOCNUM = WA_SEGMENT_LIST-DOCNUM.

WA_ORDDATA-BELNR = WA_SEGMENT_LIST-SDATA+83(35).

APPEND WA_ORDDATA TO TB_ORDDATA.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_ORDDATA INTO WA_ORDDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC EQ 0.

IF NOT SO_BELNR3 EQ WA_ORDDATA-BELNR.

DELETE TABLE TB_945 FROM WA_945.

DELETE TABLE TB_ORDDATA FROM WA_ORDDATA.

ENDIF.

ELSE.

DELETE TABLE TB_945 FROM WA_945.

ENDIF.

ENDLOOP.

ENDIF.

CLEAR : TB_SEGMENT_LIST,TB_ORDDATA,SO_BELNR3.

* Vendor invoice

IF SO_WERKS3 IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDP01'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

* if wa_segment_list-sdata+0(3) = 'AG'.

WA_ORDDATA-DOCNUM = WA_SEGMENT_LIST-DOCNUM.

WA_ORDDATA-PLAN = WA_SEGMENT_LIST-SDATA+311(04).

APPEND WA_ORDDATA TO TB_ORDDATA.

* ENDIF.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_ORDDATA INTO WA_ORDDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC EQ 0.

* TRANSLATE wa_ORDDATA-bstnr to UPPER CASE.

IF NOT SO_WERKS3 EQ WA_ORDDATA-PLAN.

DELETE TABLE TB_945 FROM WA_945.

DELETE TABLE TB_ORDDATA FROM WA_ORDDATA.

ENDIF.

ELSE.

DELETE TABLE TB_945 FROM WA_945.

ENDIF.

ENDLOOP.

ENDIF.

CLEAR : TB_SEGMENT_LIST,TB_ORDDATA,WA_ORDDATA ,SO_WERKS3.

*Plant

IF SO_IDTNR3 IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDP19'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(3) EQ '001'.

WA_ORDDATA-DOCNUM = WA_SEGMENT_LIST-DOCNUM.

WA_ORDDATA-CUSTPO = WA_SEGMENT_LIST-SDATA+3(35).

APPEND WA_ORDDATA TO TB_ORDDATA.

ENDIF.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_ORDDATA INTO WA_ORDDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC EQ 0.

TRANSLATE WA_ORDDATA-CUSTPO TO UPPER CASE. "#EC SYNTCHAR

IF NOT SO_IDTNR3 EQ WA_ORDDATA-CUSTPO.

DELETE TABLE TB_945 FROM WA_945.

DELETE TABLE TB_ORDDATA FROM WA_ORDDATA.

ENDIF.

ELSE.

DELETE TABLE TB_945 FROM WA_945.

ENDIF.

ENDLOOP.

CLEAR:SO_IDTNR3.

ENDIF.

IF SO_BELNR13 IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDK02'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(3) EQ '001'.

WA_ORDDATA-DOCNUM = WA_SEGMENT_LIST-DOCNUM.

WA_ORDDATA-BELNR = WA_SEGMENT_LIST-SDATA+3(35).

APPEND WA_ORDDATA TO TB_ORDDATA.

ENDIF.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_ORDDATA INTO WA_ORDDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC EQ 0.

* TRANSLATE wa_ORDDATA-bstnr to UPPER CASE.

IF NOT SO_BELNR13 EQ WA_ORDDATA-BELNR.

DELETE TABLE TB_945 FROM WA_945.

DELETE TABLE TB_ORDDATA FROM WA_ORDDATA.

ENDIF.

ELSE.

DELETE TABLE TB_945 FROM WA_945.

ENDIF.

ENDLOOP.

ENDIF.

CLEAR : TB_SEGMENT_LIST,TB_ORDDATA,SO_BELNR3.

CLEAR : TB_SEGMENT_LIST.

* ENDIF.

IF SO_ORGID IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDK14'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(3) = '014'.

WA_ORDDATA-DOCNUM = WA_SEGMENT_LIST-DOCNUM.

WA_ORDDATA-ORGID = WA_SEGMENT_LIST-SDATA+3(04).

APPEND WA_ORDDATA TO TB_ORDDATA.

ENDIF.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_ORDDATA INTO WA_ORDDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC EQ 0.

TRANSLATE WA_ORDDATA-ORGID TO UPPER CASE. "#EC SYNTCHAR

IF NOT SO_ORGID EQ WA_ORDDATA-ORGID.

DELETE TABLE TB_945 FROM WA_945.

DELETE TABLE TB_ORDDATA FROM WA_ORDDATA.

ENDIF.

ELSE.

DELETE TABLE TB_945 FROM WA_945.

ENDIF.

ENDLOOP.

ENDIF.

CLEAR : TB_SEGMENT_LIST,TB_ORDDATA,SO_ORGID.

CLEAR : TB_SEGMENT_LIST.

CALL SCREEN 1009.

WHEN 'CANC'.

LEAVE PROGRAM.

WHEN 'EXIT'.

LEAVE TO SCREEN 0 .

ENDCASE.

ENDMODULE. " USER_COMMAND_1013 INPUT

*&---------------------------------------------------------------------*

*& Form READ_DATA_8501

*&---------------------------------------------------------------------*

FORM READ_DATA_8501 .

DATA :LV_F(80) TYPE C,

LV_F1(45) TYPE C,

LV_F2(45) TYPE C,

LV_F3(45) TYPE C,

LV_F4(45) TYPE C,

LV_STRING TYPE STRING.

CLEAR : TB_945.

CONSTANTS : LC_MESST1(6) TYPE C VALUE 'ORDERS',

LC_MESST2(1) TYPE C VALUE '1'.

LV_F = 'MESTYP EQ LC_MESST1 and DIRECT EQ lc_messt2 '. "#EC NOTEXT

IF SO_CT1 IS NOT INITIAL AND SO_CT2 IS INITIAL.

LV_F1 = ' AND CRETIM EQ SO_CT1 '.

ENDIF.

IF SO_CT1 IS NOT INITIAL AND SO_CT2 IS NOT INITIAL.

LV_F1 = ' AND CRETIM BETWEEN SO_CT1 AND SO_CT2 '.

ENDIF.

IF SO_CR1 IS NOT INITIAL AND SO_CR2 IS INITIAL.

LV_F2 = ' AND CREDAT EQ SO_CR1 '.

ENDIF.

IF SO_CR1 IS NOT INITIAL AND SO_CR2 IS NOT INITIAL.

LV_F2 = ' AND CREDAT BETWEEN SO_CR1 AND SO_CR2 '.

ENDIF.

IF SO_CHT1 IS NOT INITIAL AND SO_CHT2 IS INITIAL.

LV_F3 = ' AND UPDTIM EQ SO_CHT1'.

ENDIF.

IF SO_CHT1 IS NOT INITIAL AND SO_CHT2 IS NOT INITIAL.

LV_F3 = ' AND UPDTIM BETWEEN SO_CHT1 AND SO_CHT2'.

ENDIF.

IF SO_CHD1 IS NOT INITIAL AND SO_CHD2 IS INITIAL.

LV_F4 = ' AND UPDDAT EQ SO_CHD1 '.

ENDIF.

IF SO_CHD1 IS NOT INITIAL AND SO_CHD2 IS NOT INITIAL.

LV_F4 = ' AND UPDDAT BETWEEN SO_CHD1 AND SO_CHD2 '.

ENDIF.

CONCATENATE LV_F LV_F1 LV_F2 LV_F3 LV_F4 ' .' INTO LV_STRING.

CLEAR : TB_94, TB_945.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_94 WHERE (LV_STRING).

DATA : LV_DESC TYPE TEDS2-DESCRP,

LV_DOCTYP TYPE EDIDC-DOCTYP .

LOOP AT TB_94 INTO WA_94.

* SELECT SINGLE DOCTYP INTO LV_DOCTYP

* FROM EDIDC WHERE DOCNUM eq WA_94-DOCNUM.

SELECT DESCRP FROM TEDS2 INTO LV_DESC WHERE STATUS = WA_94-STATUS AND LANGUA = 'EN'.

IF sy-subrc eq 0.

wa_945-docnum = wa_94-docnum.

wa_945-direct = wa_94-direct.

wa_945-status = wa_94-status.

wa_945-DESCRP = lv_desc.

wa_945-senprn = wa_94-senprn.

wa_945-recprn = wa_94-recprn.

wa_945-rcvpor = wa_94-rcvpor.

WA_945-IDOCTP = WA_94-IDOCTP.

wa_945-mestyp = wa_94-mestyp.

APPEND wa_945 to tb_945.

ENDIF.

ENDSELECT.

ENDLOOP.

ENDFORM. " READ_DATA_8501

*&---------------------------------------------------------------------*

*& Module STATUS_1014 OUTPUT

*&---------------------------------------------------------------------*

MODULE STATUS_1014 OUTPUT.

SET PF-STATUS 'MAIN1'.

* SET TITLEBAR 'XXX'.

ENDMODULE. " STATUS_1014 OUTPUT

*&---------------------------------------------------------------------*

*& Module USER_COMMAND_1014 INPUT

MODULE USER_COMMAND_1014 INPUT.

CASE sy-ucomm.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'CLEA'.

CLEAR:

SO_CT1,SO_CT2,SO_CR1,SO_CR2,SO_CHT1,SO_CHT2,SO_CHD1,SO_CHD2,

SO_FKART,SO_PARTN4,SO_BELNR4,so_belnr5,SO_IDTNR4.

WHEN 'SEAR'.

clear: wa_invdata,tb_invdata.

PERFORM read_data_8100.

* PO NUMBER

IF SO_FKART IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN TB_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDK01'.

loop at tb_segment_list into wa_segment_list.

wa_invdata-docnum = wa_segment_list-docnum.

wa_invdata-fkart = wa_segment_list-sdata+157(04).

append wa_invdata to tb_invdata.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_INVDATA INTO WA_INVDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

TRANSLATE wa_invdata-fkart to UPPER CASE. "#EC SYNTCHAR

IF NOT so_fkart eq wa_invdata-fkart .

delete TABLE tb_945 from wa_945.

delete TABLE TB_INVDATA from WA_INVDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

clear : tb_segment_list,tb_invdata,so_fkart.

* Vendor

IF SO_PARTN4 IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDKA1'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(2) EQ 'RG'.

wa_invdata-docnum = wa_segment_list-docnum.

WA_INVDATA-VEN = WA_SEGMENT_LIST-SDATA+3(17).

append wa_invdata to tb_invdata.

endif.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_INVDATA INTO WA_INVDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

* TRANSLATE wa_ORDDATA-bstnr to UPPER CASE.

IF NOT SO_PARTN4 eq WA_INVDATA-VEN.

delete TABLE tb_945 from wa_945.

delete TABLE TB_INVDATA from WA_INVDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

clear : tb_segment_list,tb_invdata, SO_PARTN4.

* Vendor invoice

IF SO_BELNR4 IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDK01'.

Loop at tb_segment_list into wa_segment_list.

wa_invdata-docnum = wa_segment_list-docnum.

WA_INVDATA-VENIN = WA_SEGMENT_LIST-SDATA+83(35).

append wa_invdata to tb_invdata.

* endif.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_INVDATA INTO WA_INVDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

* TRANSLATE wa_ORDDATA-bstnr to UPPER CASE.

IF NOT so_belnr4 eq wa_INVDATA-VENIN.

delete TABLE tb_945 from wa_945.

delete TABLE TB_INVDATA from WA_INVDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

clear : tb_segment_list,tb_invdata,so_belnr4.

*Plant

IF so_belnr5 IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDK02'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(3) EQ '002'.

wa_invdata-docnum = wa_segment_list-docnum.

WA_INVDATA-SAPVEN = WA_SEGMENT_LIST-SDATA+3(35).

append wa_invdata to tb_invdata.

endif.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_INVDATA INTO WA_INVDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

* TRANSLATE wa_ORDDATA-bstnr to UPPER CASE.

IF NOT so_belnr5 eq wa_invdata-sapven.

delete TABLE tb_945 from wa_945.

delete TABLE TB_INVDATA from WA_INVDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

clear : tb_segment_list,tb_invdata,so_belnr5.

IF SO_IDTNR4 IS NOT INITIAL.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDP19'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(3) = '002'.

wa_invdata-docnum = wa_segment_list-docnum.

WA_INVDATA-IDTNR4 = WA_SEGMENT_LIST-SDATA+3(35).

append wa_invdata to tb_invdata.

endif.

ENDLOOP.

LOOP AT TB_945 INTO WA_945 .

READ TABLE TB_INVDATA INTO WA_INVDATA WITH KEY DOCNUM = WA_945-DOCNUM.

IF SY-SUBRC eq 0.

TRANSLATE wa_INVDATA-IDTNR4 to UPPER CASE. "#EC SYNTCHAR

IF NOT so_idtnr4 eq wa_invdata-idtnr4.

delete TABLE tb_945 from wa_945.

delete TABLE TB_INVDATA from WA_INVDATA.

ENDIF.

ELSE.

delete TABLE tb_945 from wa_945.

ENDIF.

ENDLOOP.

ENDIF.

clear : tb_segment_list,tb_invdata,so_idtnr4.

CLEAR : TB_SEGMENT_LIST.

* ENDIF.

CLEAR : TB_SEGMENT_LIST.

* ENDIF.

CALL SCREEN 1009.

WHEN 'CANC'.

LEAVE PROGRAM.

WHEN 'EXIT'.

LEAVE TO SCREEN 0 .

ENDCASE.

ENDMODULE. " USER_COMMAND_1014 INPUT

*&---------------------------------------------------------------------*

*& Form READ_DATA_8100

*&---------------------------------------------------------------------*

FORM READ_DATA_8100 .

DATA :LV_F(80) TYPE C,

lv_f1(45) TYPE c,

LV_F2(45) TYPE C,

LV_F3(45) TYPE C,

LV_F4(45) TYPE C,

lv_string TYPE string.

clear : tb_945.

CONSTANTS : lc_messt1(6) TYPE c VALUE 'INVOIC',

lc_messt2(1) TYPE c VALUE '1'.

lv_f = 'MESTYP EQ LC_MESST1 AND DIRECT EQ LC_MESST2 '. "#EC NOTEXT

if so_ct1 is not INITIAL and so_ct2 is INITIAL.

lv_f1 = ' AND CRETIM EQ SO_CT1 '.

endif.

if so_ct1 is not INITIAL and so_ct2 is NOT INITIAL.

lv_f1 = ' AND CRETIM BETWEEN SO_CT1 AND SO_CT2 '.

endif.

IF SO_CR1 is not initial and so_cr2 is INITIAL.

LV_F2 = ' AND CREDAT EQ SO_CR1 '.

ENDIF.

IF SO_CR1 is not initial and so_cr2 is Not INITIAL.

LV_F2 = ' AND CREDAT BETWEEN SO_CR1 AND SO_CR2 '.

ENDIF.

if so_cht1 is not INITIAL and so_cht2 is INITIAL.

lv_f3 = ' AND UPDTIM EQ SO_CHT1'.

endif.

if so_cht1 is not INITIAL and so_cht2 is NOT INITIAL.

lv_f3 = ' AND UPDTIM BETWEEN SO_CHT1 AND SO_CHT2'.

endif.

IF SO_CHD1 is not initial and so_cHD2 is INITIAL.

LV_F4 = ' AND UPDDAT EQ SO_CHD1 '.

ENDIF.

IF SO_CHD1 is not initial and so_cHD2 is Not INITIAL.

LV_F4 = ' AND UPDDAT BETWEEN SO_CHD1 AND SO_CHD2 '.

ENDIF.

CONCATENATE lv_f lv_f1 lv_f2 lv_f3 lv_f4 ' .' INTO lv_string.

clear : tb_94, tb_945.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_94 WHERE (lv_string).

data : lv_desc TYPE teds2-descrp,

LV_DOCTYP TYPE EDIDC-DOCTYP .

loop at tb_94 INTO wa_94.

* SELECT SINGLE DOCTYP INTO LV_DOCTYP

* FROM EDIDC WHERE DOCNUM eq WA_94-DOCNUM.

SELECT descrp from teds2 into lv_desc where STATUS = wa_94-status and LANGUA = 'EN'.

IF SY-SUBRC EQ 0.

WA_945-DOCNUM = WA_94-DOCNUM.

WA_945-DIRECT = WA_94-DIRECT.

WA_945-STATUS = WA_94-STATUS.

WA_945-DESCRP = LV_DESC.

WA_945-SENPRN = WA_94-SENPRN.

WA_945-RECPRN = WA_94-RECPRN.

WA_945-RCVPOR = WA_94-RCVPOR.

WA_945-IDOCTP = WA_94-IDOCTP.

WA_945-MESTYP = WA_94-MESTYP.

APPEND WA_945 TO TB_945.

ENDIF.

ENDSELECT.

ENDLOOP.

ENDFORM. " READ_DATA_8100

* include ZMCAED_IDOC_WORKBENCH_F4IF_I01.

*&---------------------------------------------------------------------*

*& Form BDC_DYNPRO1

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --%GTP_2586 text

* --%GTP_2587 text

*----------------------------------------------------------------------*

FORM BDC_DYNPRO1 USING PROGRAM DYNPRO

.

CLEAR BDCDATA1.

BDCDATA1-PROGRAM = PROGRAM.

BDCDATA1-DYNPRO = DYNPRO.

BDCDATA1-DYNBEGIN = 'X'.

APPEND BDCDATA1.

ENDFORM. " BDC_DYNPRO1

*&---------------------------------------------------------------------*

*& Form BDC_FIELD1

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --%GTP_2591 text

* --%GTP_2592 text

*----------------------------------------------------------------------*

FORM BDC_FIELD1 USING FNAM FVAL.

CLEAR BDCDATA1.

BDCDATA1-FNAM = FNAM.

BDCDATA1-FVAL = FVAL.

APPEND BDCDATA1. "#EC .., bzw

ENDFORM. " BDC_FIELD1

*&---------------------------------------------------------------------*

*& Form BDC_TRANSACTION1

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --%GTP_2631 text

*----------------------------------------------------------------------*

FORM BDC_TRANSACTION1 USING TCODE.

DATA: L_MSTRING(480).

DATA: L_SUBRC LIKE SY-SUBRC.

CALL TRANSACTION TCODE USING BDCDATA1.

ENDFORM. " BDC_TRANSACTION1

*Text elements

*----------------------------------------------------------

* 001 NEXT

* 002 CANCEL

* 003 EXIT

* 005 IDOC Workbench

* 006 Criteria for Search in Control Records

* 020 Criteria for Search in Control Records

* 021 Criteria for Search in Data Records

*Selection texts

*----------------------------------------------------------

* SO_CRE6 Created At

* SO_CREA6 Created On

* SO_CRO6 Last Changed At

* SO_CRON6 Last Changed On

* SO_CUSPO Customer PO

* SO_GOOD Goods Issue Date

* SO_MATNR Material Number

* SO_PLANT Plant

* SO_SHIP Ship To

* SO_SOLD Sold To

* SO_VBELN Delivery

* SP_810 810

* SP_810O 810

* SP_850 850

* SP_850O 850

* SP_940 940

* SP_945 945

* SP_INB INBOUND

* SP_OUT OutBound

*Messages

*----------------------------------------------------------

*

* Message class: YSD

*001 higher value is lower then the lower value

*&---------------------------------------------------------------------*

*& Include ZMCAED_IDOC_WORKBENCH_F4IF_I01

*&---------------------------------------------------------------------*

*&---------------------------------------------------------------------*

*& Module F4IF_VALUE_REQUEST_VBELN1 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUE_REQUEST_VBELN1 INPUT.

CLEAR:TB_945, TB_SEGMENT_LIST, TB_ORDDATA, WA_ORDDATA.

REFRESH: TB_945.

TYPES: BEGIN OF TY_DELDATA1,

VBELN TYPE E1EDL20-VBELN,

END OF TY_DELDATA1.

DATA : TB_DELDATA1 TYPE STANDARD TABLE OF TY_DELDATA1,

WA_DELDATA1 TYPE TY_DELDATA1.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

DOCTYP

MESTYP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'SHPCON' AND DIRECT EQ '2'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE

TB_SEGMENT_LIST FOR ALL ENTRIES IN TB_945

WHERE DOCNUM = TB_945-DOCNUM and SEGNAM = 'E1EDL20'.

loop at tb_segment_list into wa_segment_list.

* wa_deldata-docnum = wa_segment_list-docnum.

wa_deldata1-vbeln = wa_segment_list-sdata+0(18).

append wa_deldata1 to tb_deldata1.

ENDLOOP.

sort tb_deldata1 by vbeln.

DELETE ADJACENT DUPLICATES FROM tb_deldata1.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'VBELN'

DYNPPROG = sy-cprog

DYNPNR = sy-dynnr

DYNPROFIELD = 'SO_VBELN'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_DELDATA1

.

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUE_REQUEST_VBELN1 INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUE_REQUEST_BSTNR INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUE_REQUEST_BSTNR INPUT.

CLEAR:tb_945, TB_SEGMENT_LIST, tb_orddata, wa_orddata.

REFRESH: tb_945.

TYPES: BEGIN OF TY_bstnr,

bstnr TYPE e1edl41-bstnr,

END OF TY_BSTNR.

DATA : tb_BSTNR TYPE STANDARD TABLE OF ty_BSTNR,

wa_BSTNR type ty_BSTNR.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

DOCTYP

MESTYP

FROM EDIDC INTO TABLE TB_945 where MESTYP EQ 'SHPCON' AND DIRECT EQ '2'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDL41'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(3) = '001'.

WA_BSTNR-BSTNR = WA_SEGMENT_LIST-SDATA+3(35).

APPEND WA_BSTNR TO TB_BSTNR.

ENDIF.

ENDLOOP.

SORT TB_BSTNR BY BSTNR.

DELETE ADJACENT DUPLICATES FROM TB_BSTNR.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'BSTNR'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNNR

DYNPROFIELD = 'so_BSTNR'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_BSTNR

.

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUE_REQUEST_BSTNR INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUE_WERKS INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUE_WERKS INPUT.

CLEAR:TB_945, TB_SEGMENT_LIST, TB_ORDDATA, WA_ORDDATA.

REFRESH: TB_945.

TYPES: BEGIN OF TY_WERKS,

WERKS TYPE E1EDL24-WERKS,

END OF TY_WERKS.

DATA : TB_WERKS TYPE STANDARD TABLE OF TY_WERKS,

WA_WERKS TYPE TY_WERKS.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

DOCTYP

MESTYP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'SHPCON' AND DIRECT EQ '2'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDL24'.

Loop at tb_segment_list into wa_segment_list.

* wa_deldata-docnum = wa_segment_list-docnum.

WA_werks-WERKS = WA_SEGMENT_LIST-SDATA+136(04).

append wa_werks to tb_werks.

ENDLOOP.

sort tb_werks by werks.

DELETE ADJACENT DUPLICATES FROM tb_werks.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'WERKS'

DYNPPROG = sy-cprog

DYNPNR = sy-dynnr

DYNPROFIELD = 'WERKS'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = tb_werks .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUE_WERKS INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUE_PARTNER_AG INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUE_PARTNER_AG INPUT.

CLEAR:tb_945, TB_SEGMENT_LIST, tb_orddata, wa_orddata.

REFRESH: tb_945.

TYPES: BEGIN OF TY_ship,

partn TYPE E1ADRM1-PARTNER_ID,

END OF TY_SHIP.

DATA : TB_SHIP TYPE STANDARD TABLE OF TY_SHIP,

WA_SHIP type TY_SHIP.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

DOCTYP

MESTYP

FROM EDIDC INTO TABLE TB_945 where MESTYP EQ 'SHPCON' AND DIRECT EQ '2'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1ADRM1'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(2) = 'WE'.

WA_SHIP-PARTN = WA_SEGMENT_LIST-SDATA+4(17).

APPEND WA_SHIP TO TB_SHIP.

ENDIF .

ENDLOOP.

SORT TB_SHIP BY PARTN.

DELETE ADJACENT DUPLICATES FROM TB_SHIP.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'PARTN'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNNR

DYNPROFIELD = 'SO_PARTNER_ID'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_SHIP .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUE_PARTNER_AG INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_SOLDTO INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_SOLDTO INPUT.

CLEAR:TB_945, TB_SEGMENT_LIST, TB_ORDDATA, WA_ORDDATA.

REFRESH: TB_945.

TYPES: BEGIN OF TY_SOLD,

PARTN TYPE E1ADRM1-PARTNER_ID,

END OF TY_SOLD.

DATA : TB_SOLD TYPE STANDARD TABLE OF TY_SOLD,

WA_SOLD TYPE TY_SOLD.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

DOCTYP

MESTYP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'SHPCON' AND DIRECT EQ '2'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1ADRM1'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(2) = 'AG'.

WA_SOLD-PARTN = WA_SEGMENT_LIST-SDATA+4(17).

append wa_sold to tb_sold.

ENDIF .

ENDLOOP.

sort tb_sold by PARTN.

DELETE ADJACENT DUPLICATES FROM tb_sold.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'PARTN'

DYNPPROG = sy-cprog

DYNPNR = sy-dynnr

DYNPROFIELD = 'SO_PARTNER_ID'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = tb_sold .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_SOLDTO INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_GI INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_GI INPUT.

CLEAR:tb_945, TB_SEGMENT_LIST, tb_orddata, wa_orddata.

REFRESH: tb_945.

TYPES: BEGIN OF TY_GI,

GOODI TYPE E1EDT13-NTANF,

END OF TY_GI.

DATA : TB_GI TYPE STANDARD TABLE OF TY_GI,

WA_GI type TY_GI.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

DOCTYP

MESTYP

FROM EDIDC INTO TABLE TB_945 where MESTYP EQ 'SHPCON' AND DIRECT EQ '2'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDT13'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(3) = '006'.

WA_DELDATA-DOCNUM = WA_SEGMENT_LIST-DOCNUM.

WA_GI-GOODI = WA_SEGMENT_LIST-SDATA+27(08).

APPEND WA_GI TO TB_GI.

ENDIF.

ENDLOOP.

SORT TB_GI BY GOODI.

DELETE ADJACENT DUPLICATES FROM TB_SOLD.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'GOODI'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNNR

DYNPROFIELD = 'SO_NTANF'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_GI .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_GI INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_MATNR INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_MATNR INPUT.

CLEAR:TB_945, TB_SEGMENT_LIST, TB_ORDDATA, WA_ORDDATA.

REFRESH: TB_945.

TYPES: BEGIN OF TY_MA,

MATNR TYPE E1EDL24-MATNR,

END OF TY_MA.

DATA : TB_MA TYPE STANDARD TABLE OF TY_MA,

WA_MA TYPE TY_MA.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

DOCTYP

MESTYP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'SHPCON' AND DIRECT EQ '2'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDL24'.

Loop at tb_segment_list into wa_segment_list.

WA_MA-MATNR = WA_SEGMENT_LIST-SDATA+06(24).

append WA_MA to TB_MA.

ENDLOOP.

sort tb_ma by MATNR.

DELETE ADJACENT DUPLICATES FROM tb_ma.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'MATNR'

DYNPPROG = sy-cprog

DYNPNR = sy-dynnr

DYNPROFIELD = 'SO_MATNR'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = tb_ma .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_MATNR INPUT

*&---------------------------------------------------------------------*

*& Module F41F_CUSTO INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F41F_CUSTO INPUT.

CLEAR : TB_945.

TYPES : BEGIN OF TY_CUSTP,

BELNR TYPE E1EDK02-BELNR,

END OF TY_CUSTP.

DATA :TB_CUSTP TYPE STANDARD TABLE OF TY_CUSTP,

WA_CUSTP type TY_CUSTP.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'ORDERS' and DIRECT EQ '2'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN TB_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDK02'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(3) EQ '001'.

WA_ORDDATA-DOCNUM = WA_SEGMENT_LIST-DOCNUM.

WA_CUSTP-BELNR = WA_SEGMENT_LIST-SDATA+3(35).

APPEND WA_CUSTP TO TB_CUSTP.

ENDIF.

ENDLOOP.

SORT TB_CUSTP BY BELNR.

DELETE ADJACENT DUPLICATES FROM TB_CUSTP.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'BELNR'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNNR

DYNPROFIELD = 'SO_CUSTO'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_CUSTP .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F41F_CUSTO INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_SOLD1 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_SOLD1 INPUT.

CLEAR : TB_945.

TYPES : BEGIN OF TY_SOLD1,

SOLD TYPE E1EDKA1-PARTN ,

END OF TY_SOLD1.

DATA :TB_SOLD1 TYPE STANDARD TABLE OF TY_SOLD1,

WA_SOLD1 TYPE TY_SOLD1.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'ORDERS' AND DIRECT EQ '2'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDKA1'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(2) EQ 'AG'.

WA_SOLD1-SOLD = WA_SEGMENT_LIST-SDATA+3(17).

append WA_SOLD1 to TB_SOLD1.

endif.

ENDLOOP.

sort tb_sold1 by sold.

DELETE ADJACENT DUPLICATES FROM tb_sold1.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SOLD'

DYNPPROG = sy-cprog

DYNPNR = sy-dynnr

DYNPROFIELD = 'SO_SOLD1'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = tb_SOLD1 .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_SOLD1 INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_SHIP1 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_SHIP1 INPUT.

TYPES : BEGIN OF TY_SHIP1,

SHIP TYPE E1EDKA1-PARTN ,

END OF TY_SHIP1.

DATA :TB_SHIP1 TYPE STANDARD TABLE OF TY_SHIP1,

WA_SHIP1 type TY_SHIP1.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_94 WHERE MESTYP EQ 'ORDERS' and DIRECT EQ '2'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDKA1'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(2) EQ 'WE'.

* wa_orddata-docnum = wa_segment_list-docnum.

WA_SHIP1-SHIP = WA_SEGMENT_LIST-SDATA+3(17).

APPEND WA_SHIP1 TO TB_SHIP1.

ENDIF.

ENDLOOP.

SORT TB_SHIP1 BY SHIP.

DELETE ADJACENT DUPLICATES FROM TB_SHIP1.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SHIP1'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNNR

DYNPROFIELD = 'SO_SHIP1'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_SHIP1 .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_SHIP1 INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_PLAN1 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_PLAN1 INPUT.

TYPES : BEGIN OF TY_PLAN1,

PLAN TYPE E1EDP01-WERKS,

END OF TY_PLAN1.

DATA :TB_PLAN1 TYPE STANDARD TABLE OF TY_PLAN1,

WA_PLAN1 TYPE TY_PLAN1.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'ORDERS' AND DIRECT EQ '2'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDP01'.

Loop at tb_segment_list into wa_segment_list.

wa_orddata-docnum = wa_segment_list-docnum.

WA_PLAN1-PLAN = WA_SEGMENT_LIST-SDATA+311(04).

append wa_PLAN1 to tb_plan1.

ENDLOOP.

sort tb_plan1 by plan.

DELETE ADJACENT DUPLICATES FROM tb_plan1.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'PLAN1'

DYNPPROG = sy-cprog

DYNPNR = sy-dynnr

DYNPROFIELD = 'SO_PLAN1'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = tb_plan1 .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_PLAN1 INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_SAPM INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_SAPM INPUT.

TYPES : BEGIN OF TY_SAPM,

SAPM TYPE E1EDP19-IDTNR,

END OF TY_SAPM.

DATA :TB_SAPM TYPE STANDARD TABLE OF TY_SAPM,

WA_SAPM type TY_SAPM.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'ORDERS' and DIRECT EQ '2'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDP19'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(3) = '002'.

WA_SAPM-SAPM = WA_SEGMENT_LIST-SDATA+3(35).

APPEND WA_SAPM TO TB_SAPM.

ENDIF.

ENDLOOP.

SORT TB_SAPM BY SAPM.

DELETE ADJACENT DUPLICATES FROM TB_SAPM.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SAPM'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNNR

DYNPROFIELD = 'SO_SAPM'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_SAPM .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_SAPM INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_CUSTOM INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_CUSTOM INPUT.

TYPES : BEGIN OF TY_CUSTOM,

CUSTPO TYPE E1EDP19-IDTNR,

END OF TY_CUSTOM.

DATA :TB_CUSTOM TYPE STANDARD TABLE OF TY_CUSTOM,

WA_CUSTOM TYPE TY_CUSTOM.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'ORDERS' AND DIRECT EQ '2'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM and SEGNAM = 'E1EDP19'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(03) = '001'.

WA_CUSTOM-CUSTPO = WA_SEGMENT_LIST-SDATA+3(35).

append wa_custom to tb_custom.

ENDIF.

ENDLOOP.

sort tb_custom by custpo.

DELETE ADJACENT DUPLICATES FROM tb_custom.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'CUSTPO'

DYNPPROG = sy-cprog

DYNPNR = sy-dynnr

DYNPROFIELD = 'SO_CUSTOM'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = tb_CUSTOM .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_CUSTOM INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VBELN1 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VBELN1 INPUT.

TYPES : BEGIN OF TY_SALES,

SALES TYPE E1EDP19-IDTNR,

END OF TY_SALES.

DATA :TB_SALES TYPE STANDARD TABLE OF TY_SALES,

WA_SALES type TY_SALES.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'ORDERS' and DIRECT EQ '2'. "#EC ..,

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDP19'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(03) = '003'.

WA_SALES-SALES = WA_SEGMENT_LIST-SDATA+3(35).

APPEND WA_SALES TO TB_SALES.

ENDIF.

ENDLOOP.

SORT TB_SALES BY SALES.

DELETE ADJACENT DUPLICATES FROM TB_SALES.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SALES'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNNR

DYNPROFIELD = 'SO_SALES'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_SALES .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VBELN1 INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_PO INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_PO INPUT.

TYPES : BEGIN OF TY_PO,

BELNR TYPE E1EDP02-BELNR,

END OF TY_PO.

DATA :TB_PO TYPE STANDARD TABLE OF TY_PO,

WA_PO TYPE TY_PO.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'INVOIC' AND DIRECT EQ '2'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN TB_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDP02'.

loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(3) EQ '013'.

wa_PO-belnr = wa_segment_list-sdata+3(35).

append wa_PO to tb_PO.

ENDIF.

ENDLOOP.

sort tb_po by belnr.

DELETE ADJACENT DUPLICATES FROM tb_po.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'BELNR'

DYNPPROG = sy-cprog

DYNPNR = sy-dynnr

DYNPROFIELD = 'SO_PO'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = tb_po .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_PO INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUE_VEN INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUE_VEN INPUT.

TYPES : BEGIN OF TY_VEN,

PARTN TYPE E1EDKA1-PARTN,

END OF TY_VEN.

DATA :TB_VEN TYPE STANDARD TABLE OF TY_VEN,

WA_VEN type TY_VEN.

* BELNR TYPE E1EDP02-BELNR,

* VEN TYPE E1EDKA1-PARTN,

* VENIN TYPE E1EDK02-BELNR ,

* SAPVEN TYPE E1EDK02-BELNR ,

* FKART TYPE E1EDK01-FKART_RL,

* IDTNR4 TYPE E1EDP19-IDTNR,

* END

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'INVOIC' and DIRECT EQ '2'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDKA1'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(2) EQ 'AG'.

WA_INVDATA-DOCNUM = WA_SEGMENT_LIST-DOCNUM.

WA_VEN-PARTN = WA_SEGMENT_LIST-SDATA+3(17).

APPEND WA_VEN TO TB_VEN.

ENDIF.

ENDLOOP.

SORT TB_VEN BY PARTN.

DELETE ADJACENT DUPLICATES FROM TB_VEN.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'PARTN'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNNR

DYNPROFIELD = 'SO_VEN'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_VEN .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUE_VEN INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUE_VENIN INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUE_VENIN INPUT.

TYPES : BEGIN OF TY_VENIN,

VENIN TYPE E1EDK02-BELNR ,

END OF TY_VENIN.

DATA :TB_VENIN TYPE STANDARD TABLE OF TY_VENIN,

WA_VENIN TYPE TY_VENIN.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'INVOIC' AND DIRECT EQ '2'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDK02'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(3) EQ '009'.

wa_venin-VENIN = WA_SEGMENT_LIST-SDATA+3(35).

append wa_venin to tb_venin.

endif.

ENDLOOP.

sort tb_venin by venin.

DELETE ADJACENT DUPLICATES FROM tb_venin.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'VENIN'

DYNPPROG = sy-cprog

DYNPNR = sy-dynnr

DYNPROFIELD = 'SO_VENIN'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = tb_venin .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUE_VENIN INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUE_SAPVEN INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUE_SAPVEN INPUT.

TYPES : BEGIN OF TY_SAPVEN,

SAPVEN TYPE E1EDK02-BELNR ,

END OF TY_SAPVEN.

DATA :TB_SAPVEN TYPE STANDARD TABLE OF TY_SAPVEN,

WA_SAPVEN type TY_SAPVEN.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'INVOIC' and DIRECT EQ '2'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDK02'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(3) EQ '002'.

WA_SAPVEN-SAPVEN = WA_SEGMENT_LIST-SDATA+3(35).

APPEND WA_SAPVEN TO TB_SAPVEN.

ENDIF.

ENDLOOP.

SORT TB_SAPVEN BY SAPVEN.

DELETE ADJACENT DUPLICATES FROM TB_SAPVEN.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SAPVEN'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNNR

DYNPROFIELD = 'SO_SAPVEN'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_SAPVEN .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUE_SAPVEN INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUES_DELIVERY INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUES_DELIVERY INPUT.

TYPES : BEGIN OF TY_DELIVERY,

VBELN TYPE E1EDL20-VBELN,

END OF TY_DELIVERY.

DATA :TB_DELIVERY TYPE STANDARD TABLE OF TY_DELIVERY,

WA_DELIVERY TYPE TY_DELIVERY.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'SHPORD' AND DIRECT EQ '1'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN TB_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDL20'.

loop at tb_segment_list into wa_segment_list.

wa_deldata-docnum = wa_segment_list-docnum.

WA_DELIVERY-vbeln = wa_segment_list-sdata+0(10).

append WA_DELIVERY to TB_DELIVERY.

ENDLOOP.

sort TB_DELIVERY by VBELN.

DELETE ADJACENT DUPLICATES FROM tb_delivery.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SO_DELIVERY'

DYNPPROG = sy-cprog

DYNPNR = sy-dynnr

DYNPROFIELD = 'SO_DELIVERY'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = tb_delivery .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUES_DELIVERY INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUES_BSTNR1 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUES_BSTNR1 INPUT.

TYPES : BEGIN OF TY_BSTNR1,

bstnr TYPE e1edl41-bstnr,

END OF TY_BSTNR1.

DATA :TB_BSTNR1 TYPE STANDARD TABLE OF TY_BSTNR1,

WA_BSTNR1 type TY_BSTNR1.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'SHPORD' and DIRECT EQ '1'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDL41'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(3) EQ '001'.

WA_BSTNR1-BSTNR = WA_SEGMENT_LIST-SDATA+3(35).

APPEND WA_BSTNR1 TO TB_BSTNR1.

ENDIF.

ENDLOOP.

SORT TB_BSTNR1 BY BSTNR.

DELETE ADJACENT DUPLICATES FROM TB_BSTNR1.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SO_BSTNR1'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNNR

DYNPROFIELD = 'SO_BSTNR1'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_BSTNR1 .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUES_BSTNR1 INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUES_WERKS1 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUES_WERKS1 INPUT.

TYPES : BEGIN OF TY_WERKS1,

WERKS TYPE E1EDL24-WERKS,

END OF TY_WERKS1.

DATA :TB_WERKS1 TYPE STANDARD TABLE OF TY_WERKS1,

WA_WERKS1 TYPE TY_WERKS1.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'SHPORD' AND DIRECT EQ '1'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDL24'.

Loop at tb_segment_list into wa_segment_list.

* if wa_segment_list-sdata+0(3) = 'AG'.

* wa_deldata-docnum = wa_segment_list-docnum.

WA_WERKS1-werks = WA_SEGMENT_LIST-SDATA+136(04).

append wa_WERKS1 to TB_WERKS1.

* ENDIF.

ENDLOOP.

sort TB_WERKS1 by WERKS.

DELETE ADJACENT DUPLICATES FROM tb_werks1.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SO_WERKS1'

DYNPPROG = sy-cprog

DYNPNR = sy-dynnr

DYNPROFIELD = 'SO_WERKS1'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = tb_WERKS1 .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUES_WERKS1 INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUES_SHIP2 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUES_SHIP2 INPUT.

TYPES : BEGIN OF TY_SHIP2,

SHIP TYPE E1ADRM1-PARTNER_ID ,

END OF TY_SHIP2.

DATA :TB_SHIP2 TYPE STANDARD TABLE OF TY_SHIP2,

WA_SHIP2 type TY_SHIP2.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'SHPORD' and DIRECT EQ '1'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1ADRM1'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(3) EQ 'WE'.

WA_SHIP2-SHIP = WA_SEGMENT_LIST-SDATA+4(35).

APPEND WA_SHIP2 TO TB_SHIP2.

ENDIF.

ENDLOOP.

SORT TB_SHIP2 BY SHIP.

DELETE ADJACENT DUPLICATES FROM TB_SHIP2.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SO_SHIP2'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNNR

DYNPROFIELD = 'SO_SHIP2'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_SHIP2 .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUES_SHIP2 INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUES_SOLD2 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUES_SOLD2 INPUT.

TYPES : BEGIN OF TY_SOLD2,

SOLD TYPE E1ADRM1-PARTNER_ID ,

END OF TY_SOLD2.

DATA :TB_SOLD2 TYPE STANDARD TABLE OF TY_SOLD2,

WA_SOLD2 TYPE TY_SOLD2.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'SHPORD' AND DIRECT EQ '1'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1ADRM1'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(3) EQ 'AG'.

WA_SOLD2-SOLD = WA_SEGMENT_LIST-SDATA+4(35).

append wa_sold2 to tb_sold2.

endif.

ENDLOOP.

sort TB_sold2 by SOLD.

DELETE ADJACENT DUPLICATES FROM tb_sold2.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SO_SOLD2'

DYNPPROG = sy-cprog

DYNPNR = sy-dynnr

DYNPROFIELD = 'SO_SOLD2'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = tb_sold2 .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUES_SOLD2 INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUES_MATNR2 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUES_MATNR2 INPUT.

TYPES : BEGIN OF TY_MAT,

MATNR TYPE E1EDL24-MATNR,

END OF TY_MAT.

DATA :TB_MAT TYPE STANDARD TABLE OF TY_MAT,

WA_MAT type TY_MAT.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'SHPORD' and DIRECT EQ '1'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDL24'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

WA_DELDATA-DOCNUM = WA_SEGMENT_LIST-DOCNUM.

WA_MAT-MATNR = WA_SEGMENT_LIST-SDATA+6(18).

APPEND WA_MAT TO TB_MAT.

ENDLOOP.

SORT TB_MAT BY MATNR.

DELETE ADJACENT DUPLICATES FROM TB_MAT.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SO_MATNR2'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNNR

DYNPROFIELD = 'SO_MATNR2'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_MAT .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUES_MATNR2 INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUE_PARTN3 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUE_PARTN3 INPUT.

TYPES : BEGIN OF TY_PART,

PARTN3 TYPE E1EDKA1-PARTN ,

END OF TY_PART.

DATA :TB_PART TYPE STANDARD TABLE OF TY_PART,

WA_PART TYPE TY_PART.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'ORDERS' AND DIRECT EQ '1'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN TB_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDKA1'.

loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(2) = 'LF'.

WA_PART-PARTN3 = wa_segment_list-sdata+3(17).

append WA_PART to TB_PART.

ENDIF.

ENDLOOP.

sort TB_PART by PARTN3.

DELETE ADJACENT DUPLICATES FROM tb_part.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SO_PARTN3'

DYNPPROG = sy-cprog

DYNPNR = sy-dynnr

DYNPROFIELD = 'SO_PARTN3'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = tb_part .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUE_PARTN3 INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUE_BELNR3 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUE_BELNR3 INPUT.

TYPES : BEGIN OF TY_BEL,

BELNR TYPE E1EDK02-BELNR,

END OF TY_BEL.

DATA :TB_BEL TYPE STANDARD TABLE OF TY_BEL,

WA_BEL type TY_BEL.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'ORDERS' and DIRECT EQ '1'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDK01'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

WA_BEL-BELNR = WA_SEGMENT_LIST-SDATA+83(35).

APPEND WA_BEL TO TB_BEL.

ENDLOOP.

SORT TB_BEL BY BELNR.

DELETE ADJACENT DUPLICATES FROM TB_BEL.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SO_BELNR3'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNNR

DYNPROFIELD = 'SO_BELNR3'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_BEL .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUE_BELNR3 INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUE_WERKS3 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUE_WERKS3 INPUT.

TYPES : BEGIN OF TY_WERKS3,

WERKS TYPE E1EDL24-WERKS,

END OF TY_WERKS3.

DATA :TB_WERKS3 TYPE STANDARD TABLE OF TY_WERKS3,

WA_WERKS3 TYPE TY_WERKS3.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'ORDERS' AND DIRECT EQ '1'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDP01'.

Loop at tb_segment_list into wa_segment_list.

WA_WERKS3-WERKS = WA_SEGMENT_LIST-SDATA+311(04).

append WA_WERKS3 to TB_WERKS3 .

ENDLOOP.

sort TB_WERKS3 by WERKS.

DELETE ADJACENT DUPLICATES FROM tb_werks3.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SO_WERKS3'

DYNPPROG = sy-cprog

DYNPNR = sy-dynnr

DYNPROFIELD = 'SO_WERKS3'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = tb_werks3 .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUE_WERKS3 INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUE_IDTNR3 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUE_IDTNR3 INPUT.

TYPES : BEGIN OF TY_IDTNR3,

CUSTPO TYPE E1EDP19-IDTNR,

END OF TY_IDTNR3.

DATA :TB_IDTNR3 TYPE STANDARD TABLE OF TY_IDTNR3,

WA_IDTNR3 type TY_IDTNR3.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'ORDERS' and DIRECT EQ '1'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDP19'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(3) EQ '001'.

WA_ORDDATA-DOCNUM = WA_SEGMENT_LIST-DOCNUM.

WA_IDTNR3-CUSTPO = WA_SEGMENT_LIST-SDATA+3(35).

APPEND WA_IDTNR3 TO TB_IDTNR3.

ENDIF.

ENDLOOP.

SORT TB_IDTNR3 BY CUSTPO.

DELETE ADJACENT DUPLICATES FROM TB_IDTNR3.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SO_IDTNR3'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNNR

DYNPROFIELD = 'SO_IDTNR3'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_IDTNR3 .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUE_IDTNR3 INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUE_BELNR13 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUE_BELNR13 INPUT.

TYPES : BEGIN OF TY_BELNR13,

BELNR TYPE E1EDK02-BELNR,

END OF TY_BELNR13.

DATA :TB_BELNR13 TYPE STANDARD TABLE OF TY_BELNR13,

WA_BELNR13 TYPE TY_BELNR13.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'ORDERS' AND DIRECT EQ '1'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDK02'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(3) EQ '001'.

wa_orddata-docnum = wa_segment_list-docnum.

WA_BELNR13-BELNR = WA_SEGMENT_LIST-SDATA+3(35).

append wa_belnr13 to tb_belnr13.

endif.

ENDLOOP.

sort TB_BELNR13 by BELNR.

DELETE ADJACENT DUPLICATES FROM TB_BELNR13.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SO_BELNR3'

DYNPPROG = sy-cprog

DYNPNR = sy-dynnr

DYNPROFIELD = 'SO_BELNR3'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_BELNR13 .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUE_BELNR13 INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUE_ORGID INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUE_ORGID INPUT.

TYPES : BEGIN OF TY_ORGID,

ORGID TYPE E1EDK14-ORGID,

END OF TY_ORGID.

DATA :TB_ORGID TYPE STANDARD TABLE OF TY_ORGID,

WA_ORGID type TY_ORGID.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'ORDERS' and DIRECT EQ '1'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDK14'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(3) = '014'.

WA_ORGID-ORGID = WA_SEGMENT_LIST-SDATA+3(04).

APPEND WA_ORGID TO TB_ORGID.

ENDIF.

ENDLOOP.

SORT TB_ORGID BY ORGID.

DELETE ADJACENT DUPLICATES FROM TB_ORGID.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SO_ORGID'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNNR

DYNPROFIELD = 'SO_ORGID'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_ORGID .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUE_ORGID INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUES_FKART INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUES_FKART INPUT.

TYPES : BEGIN OF TY_FKART,

FKART TYPE E1EDK01-FKART_RL,

END OF TY_FKART.

DATA :TB_FKART TYPE STANDARD TABLE OF TY_FKART,

WA_FKART TYPE TY_FKART.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'INVOIC' AND DIRECT EQ '1'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN TB_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDK01'.

loop at tb_segment_list into wa_segment_list.

wa_invdata-docnum = wa_segment_list-docnum.

WA_FKART-fkart = wa_segment_list-sdata+157(04).

append WA_FKART to TB_FKART.

ENDLOOP.

sort TB_FKART by FKART.

DELETE ADJACENT DUPLICATES FROM TB_FKART.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SO_FKART'

DYNPPROG = sy-cprog

DYNPNR = sy-dynnr

DYNPROFIELD = 'SO_FKART'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_FKART .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUES_FKART INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUES_PARTN4 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUES_PARTN4 INPUT.

TYPES : BEGIN OF TY_PARTN4,

PARTN TYPE E1EDKA1-PARTN,

END OF TY_PARTN4.

DATA :TB_PARTN4 TYPE STANDARD TABLE OF TY_PARTN4,

WA_PARTN4 type TY_PARTN4.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'INVOIC' and DIRECT EQ '1'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDKA1'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(2) EQ 'RG'.

WA_PARTN4-PARTN = WA_SEGMENT_LIST-SDATA+3(17).

APPEND WA_PARTN4 TO TB_PARTN4.

ENDIF.

ENDLOOP.

SORT TB_PARTN4 BY PARTN.

DELETE ADJACENT DUPLICATES FROM TB_PARTN4.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SO_PARTN4'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNNR

DYNPROFIELD = 'SO_PARTN4'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_PARTN4 .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUES_PARTN4 INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUES_BELNR4 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUES_BELNR4 INPUT.

TYPES : BEGIN OF TY_BELNR4,

BELNR4 TYPE E1EDK02-BELNR ,

END OF TY_BELNR4.

DATA :TB_BELNR4 TYPE STANDARD TABLE OF TY_BELNR4,

WA_BELNR4 TYPE TY_BELNR4.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'INVOIC' AND DIRECT EQ '1'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDK01'.

Loop at tb_segment_list into wa_segment_list.

WA_BELNR4-BELNR4 = WA_SEGMENT_LIST-SDATA+83(35).

append WA_BELNR4 to TB_BELNR4.

* endif.

ENDLOOP.

sort TB_BELNR4 by BELNR4.

DELETE ADJACENT DUPLICATES FROM TB_BELNR4.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SO_BELNR4'

DYNPPROG = sy-cprog

DYNPNR = sy-dynnr

DYNPROFIELD = 'SO_BELNR4'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_BELNR4 .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUES_BELNR4 INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VLAUES_BELNR5 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VLAUES_BELNR5 INPUT.

TYPES : BEGIN OF TY_BELNR5,

BELNR5 TYPE E1EDK02-BELNR ,

END OF TY_BELNR5.

DATA :TB_BELNR5 TYPE STANDARD TABLE OF TY_BELNR5,

WA_BELNR5 type TY_BELNR5.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'INVOIC' and DIRECT EQ '1'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = TB_945-DOCNUM AND SEGNAM = 'E1EDK02'.

LOOP AT TB_SEGMENT_LIST INTO WA_SEGMENT_LIST.

IF WA_SEGMENT_LIST-SDATA+0(3) EQ '002'.

WA_INVDATA-DOCNUM = WA_SEGMENT_LIST-DOCNUM.

WA_BELNR5-BELNR5 = WA_SEGMENT_LIST-SDATA+3(35).

APPEND WA_BELNR5 TO TB_BELNR5.

ENDIF.

ENDLOOP.

SORT TB_BELNR5 BY BELNR5.

DELETE ADJACENT DUPLICATES FROM TB_BELNR5.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SO_BELNR5'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNNR

DYNPROFIELD = 'SO_BELNR5'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_BELNR5 .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VLAUES_BELNR5 INPUT

*&---------------------------------------------------------------------*

*& Module F4IF_VALUES_IDTNR4 INPUT

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

MODULE F4IF_VALUES_IDTNR4 INPUT.

TYPES : BEGIN OF TY_IDTNR4,

IDTNR4 TYPE E1EDP19-IDTNR,

END OF TY_IDTNR4.

DATA :TB_IDTNR4 TYPE STANDARD TABLE OF TY_IDTNR4,

WA_IDTNR4 TYPE TY_IDTNR4.

SELECT DOCNUM

DIRECT

STATUS

SNDPRN

RCVPRN

RCVPOR

MESTYP

IDOCTP

FROM EDIDC INTO TABLE TB_945 WHERE MESTYP EQ 'INVOIC' AND DIRECT EQ '1'.

SELECT DOCNUM SEGNUM SEGNAM SDATA FROM EDID4 INTO TABLE TB_SEGMENT_LIST FOR ALL ENTRIES IN tb_945

WHERE DOCNUM = tb_945-DOCNUM AND SEGNAM = 'E1EDP19'.

Loop at tb_segment_list into wa_segment_list.

if wa_segment_list-sdata+0(3) = '002'.

WA_IDTNR4-IDTNR4 = WA_SEGMENT_LIST-SDATA+3(35).

append WA_IDTNR4 to TB_IDTNR4.

endif.

ENDLOOP.

sort TB_IDTNR4 by IDTNR4.

DELETE ADJACENT DUPLICATES FROM TB_IDTNR4.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'SO_IDTNR4'

DYNPPROG = sy-cprog

DYNPNR = sy-dynnr

DYNPROFIELD = 'SO_IDTNR4'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = TB_IDTNR4 .

* IF SY-SUBRC %LT%GT 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

* ENDIF.

ENDMODULE. " F4IF_VALUES_IDTNR4 INPUT

*&SPWIZARD: DECLARATION OF TABLECONTROL 'TC_102' ITSELF

CONTROLS: TC_102 TYPE TABLEVIEW USING SCREEN 1009.

*&SPWIZARD: LINES OF TABLECONTROL 'TC_102'

DATA: G_TC_102_LINES LIKE SY-LOOPC.

*&SPWIZARD: OUTPUT MODULE FOR TC 'TC_102'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR

MODULE TC_102_CHANGE_TC_ATTR OUTPUT.

DESCRIBE TABLE TB_945 LINES TC_102-lines.

ENDMODULE.

*&SPWIZARD: OUTPUT MODULE FOR TC 'TC_102'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: GET LINES OF TABLECONTROL

MODULE TC_102_GET_LINES OUTPUT.

G_TC_102_LINES = SY-LOOPC.

ENDMODULE.

*&SPWIZARD: INPUT MODULE FOR TC 'TC_102'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: PROCESS USER COMMAND

MODULE TC_102_USER_COMMAND INPUT.

OK_CODE = SY-UCOMM.

PERFORM USER_OK_TC USING 'TC_102'

'TB_945'

' '

CHANGING OK_CODE.

SY-UCOMM = OK_CODE.

ENDMODULE.

*----------------------------------------------------------------------*

* INCLUDE TABLECONTROL_FORMS *

*----------------------------------------------------------------------*

*&---------------------------------------------------------------------*

*& Form USER_OK_TC *

*&---------------------------------------------------------------------*

FORM USER_OK_TC USING P_TC_NAME TYPE DYNFNAM

P_TABLE_NAME

P_MARK_NAME

CHANGING P_OK LIKE SY-UCOMM.

*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*

DATA: L_OK TYPE SY-UCOMM,

L_OFFSET TYPE I.

*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

*&SPWIZARD: Table control specific operations *

*&SPWIZARD: evaluate TC name and operations *

SEARCH P_OK FOR P_TC_NAME.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

L_OFFSET = STRLEN( P_TC_NAME ) + 1.

L_OK = P_OK+L_OFFSET.

*&SPWIZARD: execute general and TC specific operations *

CASE L_OK.

WHEN 'INSR'. "insert row

PERFORM FCODE_INSERT_ROW USING P_TC_NAME

P_TABLE_NAME.

CLEAR P_OK.

WHEN 'DELE'. "delete row

PERFORM FCODE_DELETE_ROW USING P_TC_NAME

P_TABLE_NAME

P_MARK_NAME.

CLEAR P_OK.

WHEN 'P--' OR "top of list

'P-' OR "previous page

'P+' OR "next page

'P++'. "bottom of list

PERFORM COMPUTE_SCROLLING_IN_TC USING P_TC_NAME

L_OK.

CLEAR P_OK.

* WHEN 'L--'. "total left

* PERFORM FCODE_TOTAL_LEFT USING P_TC_NAME.

*

* WHEN 'L-'. "column left

* PERFORM FCODE_COLUMN_LEFT USING P_TC_NAME.

*

* WHEN 'R+'. "column right

* PERFORM FCODE_COLUMN_RIGHT USING P_TC_NAME.

*

* WHEN 'R++'. "total right

* PERFORM FCODE_TOTAL_RIGHT USING P_TC_NAME.

*

WHEN 'MARK'. "mark all filled lines

PERFORM FCODE_TC_MARK_LINES USING P_TC_NAME

P_TABLE_NAME

P_MARK_NAME .

CLEAR P_OK.

WHEN 'DMRK'. "demark all filled lines

PERFORM FCODE_TC_DEMARK_LINES USING P_TC_NAME

P_TABLE_NAME

P_MARK_NAME .

CLEAR P_OK.

* WHEN 'SASCEND' OR

* 'SDESCEND'. "sort column

* PERFORM FCODE_SORT_TC USING P_TC_NAME

* l_ok.

ENDCASE.

ENDFORM. " USER_OK_TC

*&---------------------------------------------------------------------*

*& Form FCODE_INSERT_ROW *

*&---------------------------------------------------------------------*

FORM fcode_insert_row

USING P_TC_NAME TYPE DYNFNAM

P_TABLE_NAME .

*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*

DATA L_LINES_NAME LIKE FELD-NAME.

DATA L_SELLINE LIKE SY-STEPL.

DATA L_LASTLINE TYPE I.

DATA L_LINE TYPE I.

DATA L_TABLE_NAME LIKE FELD-NAME.

FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL.

FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.

FIELD-SYMBOLS <LINES> TYPE I.

*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

ASSIGN (P_TC_NAME) TO <TC>.

*&SPWIZARD: get the table, which belongs to the tc *

CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body

ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline

*&SPWIZARD: get looplines of TableControl *

CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_LINES_NAME.

ASSIGN (L_LINES_NAME) TO <LINES>.

*&SPWIZARD: get current line *

GET CURSOR LINE L_SELLINE.

IF SY-SUBRC <> 0. " append line to table

L_SELLINE = <TC>-LINES + 1.

*&SPWIZARD: set top line *

IF L_SELLINE > <LINES>.

<TC>-TOP_LINE = L_SELLINE - <LINES> + 1 .

ELSE.

<TC>-TOP_LINE = 1.

ENDIF.

ELSE. " insert line into table

L_SELLINE = <TC>-TOP_LINE + L_SELLINE - 1.

L_LASTLINE = <TC>-TOP_LINE + <LINES> - 1.

ENDIF.

*&SPWIZARD: set new cursor line *

L_LINE = L_SELLINE - <TC>-TOP_LINE + 1.

*&SPWIZARD: insert initial line *

INSERT INITIAL LINE INTO <TABLE> INDEX L_SELLINE.

<TC>-LINES = <TC>-LINES + 1.

*&SPWIZARD: set cursor *

SET CURSOR LINE L_LINE.

ENDFORM. " FCODE_INSERT_ROW

*&---------------------------------------------------------------------*

*& Form FCODE_DELETE_ROW *

*&---------------------------------------------------------------------*

FORM fcode_delete_row

USING P_TC_NAME TYPE DYNFNAM

P_TABLE_NAME

P_MARK_NAME .

*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*

DATA L_TABLE_NAME LIKE FELD-NAME.

FIELD-SYMBOLS <TC> TYPE cxtab_control.

FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.

FIELD-SYMBOLS <WA>.

FIELD-SYMBOLS <MARK_FIELD>.

*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

ASSIGN (P_TC_NAME) TO <TC>.

*&SPWIZARD: get the table, which belongs to the tc *

CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body

ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline

*&SPWIZARD: delete marked lines *

DESCRIBE TABLE <TABLE> LINES <TC>-LINES.

LOOP AT <TABLE> ASSIGNING <WA>.

*&SPWIZARD: access to the component 'FLAG' of the table header *

ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.

IF <MARK_FIELD> = 'X'.

DELETE <TABLE> INDEX SYST-TABIX.

IF SY-SUBRC = 0.

<TC>-LINES = <TC>-LINES - 1.

ENDIF.

ENDIF.

ENDLOOP.

ENDFORM. " FCODE_DELETE_ROW

*&---------------------------------------------------------------------*

*& Form COMPUTE_SCROLLING_IN_TC

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* -->P_TC_NAME name of tablecontrol

* -->P_OK ok code

*----------------------------------------------------------------------*

FORM COMPUTE_SCROLLING_IN_TC USING P_TC_NAME

P_OK.

*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*

DATA L_TC_NEW_TOP_LINE TYPE I.

DATA L_TC_NAME LIKE FELD-NAME.

DATA L_TC_LINES_NAME LIKE FELD-NAME.

DATA L_TC_FIELD_NAME LIKE FELD-NAME.

FIELD-SYMBOLS <TC> TYPE cxtab_control.

FIELD-SYMBOLS <LINES> TYPE I.

*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

ASSIGN (P_TC_NAME) TO <TC>.

*&SPWIZARD: get looplines of TableControl *

CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_TC_LINES_NAME.

ASSIGN (L_TC_LINES_NAME) TO <LINES>.

*&SPWIZARD: is no line filled? *

IF <TC>-LINES = 0.

*&SPWIZARD: yes, ... *

L_TC_NEW_TOP_LINE = 1.

ELSE.

*&SPWIZARD: no, ... *

CALL FUNCTION 'SCROLLING_IN_TABLE'

EXPORTING

ENTRY_ACT = <TC>-TOP_LINE

ENTRY_FROM = 1

ENTRY_TO = <TC>-LINES

LAST_PAGE_FULL = 'X'

LOOPS = <LINES>

OK_CODE = P_OK

OVERLAPPING = 'X'

IMPORTING

ENTRY_NEW = L_TC_NEW_TOP_LINE

EXCEPTIONS

* NO_ENTRY_OR_PAGE_ACT = 01

* NO_ENTRY_TO = 02

* NO_OK_CODE_OR_PAGE_GO = 03

OTHERS = 0.

ENDIF.

*&SPWIZARD: get actual tc and column *

GET CURSOR FIELD L_TC_FIELD_NAME

AREA L_TC_NAME.

IF SYST-SUBRC = 0.

IF L_TC_NAME = P_TC_NAME.

*&SPWIZARD: et actual column *

SET CURSOR FIELD L_TC_FIELD_NAME LINE 1.

ENDIF.

ENDIF.

*&SPWIZARD: set the new top line *

<TC>-TOP_LINE = L_TC_NEW_TOP_LINE.

ENDFORM. " COMPUTE_SCROLLING_IN_TC

*&---------------------------------------------------------------------*

*& Form FCODE_TC_MARK_LINES

*&---------------------------------------------------------------------*

* marks all TableControl lines

*----------------------------------------------------------------------*

* -->P_TC_NAME name of tablecontrol

*----------------------------------------------------------------------*

FORM FCODE_TC_MARK_LINES USING P_TC_NAME

P_TABLE_NAME

P_MARK_NAME.

*&SPWIZARD: EGIN OF LOCAL DATA-----------------------------------------*

DATA L_TABLE_NAME LIKE FELD-NAME.

FIELD-SYMBOLS <TC> TYPE cxtab_control.

FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.

FIELD-SYMBOLS <WA>.

FIELD-SYMBOLS <MARK_FIELD>.

*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

ASSIGN (P_TC_NAME) TO <TC>.

*&SPWIZARD: get the table, which belongs to the tc *

CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body

ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline

*&SPWIZARD: mark all filled lines *

LOOP AT <TABLE> ASSIGNING <WA>.

*&SPWIZARD: access to the component 'FLAG' of the table header *

ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.

<MARK_FIELD> = 'X'.

ENDLOOP.

ENDFORM. "fcode_tc_mark_lines

*&---------------------------------------------------------------------*

*& Form FCODE_TC_DEMARK_LINES

*&---------------------------------------------------------------------*

* demarks all TableControl lines

*----------------------------------------------------------------------*

* -->P_TC_NAME name of tablecontrol

*----------------------------------------------------------------------*

FORM FCODE_TC_DEMARK_LINES USING P_TC_NAME

P_TABLE_NAME

P_MARK_NAME .

*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*

DATA L_TABLE_NAME LIKE FELD-NAME.

FIELD-SYMBOLS <TC> TYPE cxtab_control.

FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.

FIELD-SYMBOLS <WA>.

FIELD-SYMBOLS <MARK_FIELD>.

*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

ASSIGN (P_TC_NAME) TO <TC>.

*&SPWIZARD: get the table, which belongs to the tc *

CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body

ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline

*&SPWIZARD: demark all filled lines *

LOOP AT <TABLE> ASSIGNING <WA>.

*&SPWIZARD: access to the component 'FLAG' of the table header *

ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.

<MARK_FIELD> = SPACE.

ENDLOOP.

ENDFORM. "fcode_tc_mark_lines

*&SPWIZARD: DECLARATION OF TABLECONTROL 'TC_103' ITSELF

CONTROLS: TC_103 TYPE TABLEVIEW USING SCREEN 1009.

*&SPWIZARD: LINES OF TABLECONTROL 'TC_103'

DATA: G_TC_103_LINES LIKE SY-LOOPC.

*&SPWIZARD: OUTPUT MODULE FOR TC 'TC_103'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR

MODULE TC_103_CHANGE_TC_ATTR OUTPUT.

DESCRIBE TABLE TB_945 LINES TC_103-lines.

ENDMODULE.

*&SPWIZARD: OUTPUT MODULE FOR TC 'TC_103'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: GET LINES OF TABLECONTROL

MODULE TC_103_GET_LINES OUTPUT.

G_TC_103_LINES = SY-LOOPC.

ENDMODULE.

*&SPWIZARD: INPUT MODULE FOR TC 'TC_103'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: PROCESS USER COMMAND

MODULE TC_103_USER_COMMAND INPUT.

OK_CODE = SY-UCOMM.

PERFORM USER_OK_TC USING 'TC_103'

'TB_945'

' '

CHANGING OK_CODE.

SY-UCOMM = OK_CODE.

ENDMODULE.

  • No labels