SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Planned Orders Outbound Interface



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> PP
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Wed Sep 05, 2007 7:57 pm    Post subject: Planned Orders Outbound Interface Reply with quote

Author: Aveek Ghose

Creation of planned order IDOCs to a given selection This program selects to an input given via the selection screen the corresponding planned orders from the database. Then the function module for creation of planned order idocs is called.
In general this report is called from the report RCCLTRAN, but it can also be used for its own.

Code:
*&---------------------------------------------------------------------*
************************************************************************
* PROGRAM....... YRCCPLAF
* TITLE......... Planned Orders Outbound Interface
* AUTHOR........ Aveek Ghose
* DATE WRITTEN.. 15/09/2006
* R/3 RELEASE... 4.6C
* =====================================================================*
* COPIED FROM... N/A
* DESCRIPTION...
*& Creation of planned order IDOCs to a given selection                *
*& This program selects to an input given via the selection screen the *
*& corresponding planned orders from the database. Then the function   *
*& module for creation of planned order idocs is called.               *
*& In general this report is called from the report RCCLTRAN, but it   *
*& can also be used for its own.                                      *
* =====================================================================*
* PROGRAM TYPE.. Outbound Interface
* DEV. CLASS.... ZPLN
* LOGICAL DB.... N/A
* =====================================================================*
* SCREENS....... N/A
* GUI TITLE..... N/A
* GUI STATUS.... N/A
* TRANSACTIONS.. N/A
* USER EXITS.... N/A
* =====================================================================*
* CHANGE HISTORY                                                       *
* Date       By        Correction Number & Brief Description     Release
*----------------------------------------------------------------------*
* Tables / Structures
*----------------------------------------------------------------------*

REPORT YRCCPLAF

 NO STANDARD PAGE HEADING

        MESSAGE-ID z001

        LINE-COUNT 65(0)

        LINE-SIZE 255.

.

INCLUDE YRCCL_CONSTANTS.

DATA : CREATED_MASTERIDOCS_PLO LIKE SY-TABIX.

*................  Definition of local data  ..........................*

* parallel >>>>>>>>>>>>>>>>

DATA: T_PLAFKEYPACK LIKE PLAF  OCCURS 0 WITH HEADER LINE,

      H_COUNTER TYPE I,

      H_PARALLEL LIKE BDFIELDS-PARALLEL.

* parallel <<<<<<<<<<<<<<<<

DATA : F_COUNTER TYPE I.              "DS001 Counter for IDocs

*>> Global data declaration

INCLUDE PLODATA.

INCLUDE RCPLOTOP.

INCLUDE ZRCORDTOP2.

*SELECTION-SCREEN SKIP 1.

**>> Logical system comes from Report RCCLTRANS

*SELECTION-SCREEN BEGIN OF LINE.

*SELECTION-SCREEN COMMENT 3(20) TEXT-001.

*SELECTION-SCREEN POSITION 35.

*PARAMETERS OPT_SYS LIKE TBDLST-LOGSYS.

*SELECTION-SCREEN END OF LINE.

*

**>> Messagetype comes from Report RCCLTRANS

*SELECTION-SCREEN BEGIN OF LINE.

*SELECTION-SCREEN COMMENT 3(20) TEXT-002.

*SELECTION-SCREEN POSITION 35.

*PARAMETERS MESTYP LIKE TBDME-MESTYP.

*SELECTION-SCREEN END OF LINE.

*

*SELECTION-SCREEN SKIP 1.

*

**>> Global selection parameters

*SELECTION-SCREEN BEGIN OF BLOCK GLOB WITH FRAME TITLE TEXT-003.

*SELECTION-SCREEN BEGIN OF LINE.

*SELECTION-SCREEN COMMENT 1(15) TEXT-009.

*SELECTION-SCREEN POSITION 33.

*PARAMETERS: DATE_FR LIKE SY-DATUM OBLIGATORY.

*SELECTION-SCREEN COMMENT 52(3) TEXT-010.

*SELECTION-SCREEN POSITION 58.

*PARAMETERS: DATE_TO LIKE SY-DATUM OBLIGATORY.

*SELECTION-SCREEN END OF LINE.

*SELECT-OPTIONS: DISPO_GL FOR MARC-DISPO,

*                MATNR_GL FOR MARA-MATNR MATCHCODE OBJECT MAT1,

*                ARBPL_GL FOR CRHD-ARBPL MATCHCODE OBJECT CRAM,

*                WERKS_GL FOR MARC-WERKS.

** Planning scenario not a ranges table, changed by Biegler 27.06.96

*PARAMETERS:     PLSCN LIKE PLSC-PLSCN.

*

** do not select from MARC, but use ranges tables directly.

** matnr_gl and werks_gl must have the same length.

*PARAMETERS:     NO_SEL TYPE C DEFAULT ' ' NO-DISPLAY.

*SELECTION-SCREEN END OF BLOCK GLOB.

*

*SELECTION-SCREEN SKIP 1.

*

**>> Selection for planned orders

*SELECTION-SCREEN BEGIN OF BLOCK PLORD WITH FRAME TITLE TEXT-005.

*SELECT-OPTIONS: DISPO_PL FOR MARC-DISPO,

*                MATNR_PL FOR MARA-MATNR MATCHCODE OBJECT MAT1,

*                ARBPL_PL FOR CRHD-ARBPL MATCHCODE OBJECT CRAM,

*                WERKS_PL FOR MARC-WERKS.

*SELECTION-SCREEN END OF BLOCK PLORD.

*

*

** Parallel >>>>>>>>>>>>>>>>

*SELECTION-SCREEN: SKIP 1,

*                  BEGIN OF BLOCK PARALLEL_PROCESSING

*                                       WITH FRAME TITLE TEXT-011,

*                  BEGIN OF LINE,

*                  COMMENT 1(30) TEXT-012 FOR FIELD RFCGR,

*                  POSITION 33.

*PARAMETERS: RFCGR LIKE BDFIELDS-RFCGR.

*SELECTION-SCREEN: END OF LINE,

*                  BEGIN OF LINE,

*                  COMMENT 1(30) TEXT-013 FOR FIELD PSIZE,

*                  POSITION 33.

*PARAMETERS: PSIZE LIKE BDFIELDS-PSIZE DEFAULT 20.

*SELECTION-SCREEN: END OF LINE,

*                  END OF BLOCK PARALLEL_PROCESSING.

** Parallel <<<<<<<<<<<<<<<<

SELECTION-SCREEN SKIP 1.

*>> Logical system comes from Report RCCLTRANS

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 3(20) TEXT-001.

SELECTION-SCREEN POSITION 35.

PARAMETERS OPT_SYS LIKE TBDLST-LOGSYS.

SELECTION-SCREEN END OF LINE.

*>> Messagetype comes from Report RCCLTRANS

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 3(20) TEXT-002.

SELECTION-SCREEN POSITION 35.

PARAMETERS MESTYP LIKE TBDME-MESTYP.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP 1.

*>> Global selection parameters

SELECTION-SCREEN BEGIN OF BLOCK GLOB WITH FRAME TITLE TEXT-003.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 1(15) TEXT-009.

SELECTION-SCREEN POSITION 33.

PARAMETERS: DATE_FR LIKE SY-DATUM. " OBLIGATORY.

SELECTION-SCREEN COMMENT 52(3) TEXT-010.

SELECTION-SCREEN POSITION 58.

PARAMETERS: DATE_TO LIKE SY-DATUM. " OBLIGATORY.

SELECTION-SCREEN END OF LINE.

SELECT-OPTIONS: DISPO_GL FOR MARC-DISPO,

                MATNR_GL FOR MARA-MATNR MATCHCODE OBJECT MAT1,

*MOD-002

                MATNR_EU FOR MARA-MATNR MATCHCODE OBJECT MAT1,

*MOD-002

                ARBPL_GL FOR CRHD-ARBPL MATCHCODE OBJECT CRAM,

                WERKS_GL FOR MARC-WERKS.

* Planning scenario not a ranges table, changed by Biegler 27.06.96

PARAMETERS:     PLSCN LIKE PLSC-PLSCN.

* do not select from MARC, but use ranges tables directly.

* matnr_gl and werks_gl must have the same length.

PARAMETERS:     NO_SEL TYPE C DEFAULT ' ' NO-DISPLAY.

SELECTION-SCREEN END OF BLOCK GLOB.

SELECTION-SCREEN SKIP 1.

*>> Selection for planned orders

*SELECTION-SCREEN BEGIN OF BLOCK PLORD WITH FRAME TITLE TEXT-005.

SELECT-OPTIONS: DISPO_PL FOR MARC-DISPO,

                MATNR_PL FOR MARA-MATNR MATCHCODE OBJECT MAT1,

                ARBPL_PL FOR CRHD-ARBPL MATCHCODE OBJECT CRAM,

                WERKS_PL FOR MARC-WERKS.

*SELECTION-SCREEN END OF BLOCK PLORD.

* Parallel >>>>>>>>>>>>>>>>

SELECTION-SCREEN: SKIP 1,

                  BEGIN OF BLOCK PARALLEL_PROCESSING

                                       WITH FRAME TITLE TEXT-011,

                  BEGIN OF LINE,

                  COMMENT 1(30) TEXT-012 FOR FIELD RFCGR,

                  POSITION 33.

PARAMETERS: RFCGR LIKE BDFIELDS-RFCGR.

SELECTION-SCREEN: END OF LINE,

                  BEGIN OF LINE,

                  COMMENT 1(30) TEXT-013 FOR FIELD PSIZE,

                  POSITION 33.

PARAMETERS: PSIZE LIKE BDFIELDS-PSIZE DEFAULT 20.

SELECTION-SCREEN: END OF LINE,

                  END OF BLOCK PARALLEL_PROCESSING.

* Parallel <<<<<<<<<<<<<<<<

INCLUDE YRCCLPLOZ.

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

*   INCLUDE YRCCLPLOZ                                                  *

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

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

*&  Include           YRCCLPLOZ

************************************************************************

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

*   INCLUDE RCCLPLOZ                                                   *

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

* WARNING ! This include was changed for parallel processing.

* Due to this it can only be used from the report RCCLPLAF

* because of the local data definition there.  // 04.97 kaas

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

*&   Event START-OF-SELECTION

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

START-OF-SELECTION.

* BEGIN OF INSERTION DS001

* get the entry of the last program run

  select single for update * from ycloidownlprot

                  where logsys = OPT_SYS and

                        DOWNLOADTYPE EQ C_DOWNL_PLANNED_ORDERS.

*MOD-001

*  if YCLOIDOWNLPROT-IN_PROGRESS eq CLOI_TRUE.

** program is already running, do not allow to start again

*    write : / text-004, YCLOIDOWNLPROT-USERNAME.

*    exit.

*  endif.

*MOD-001

* update the entry with the current values to mark program as running

  YCLOIDOWNLPROT-MANDT        = SY-MANDT.

  YCLOIDOWNLPROT-LOGSYS       = OPT_SYS.

  YCLOIDOWNLPROT-START_DATE   = SY-DATUM.

  YCLOIDOWNLPROT-START_TIME   = SY-UZEIT.

  YCLOIDOWNLPROT-USERNAME     = SY-UNAME.

  YCLOIDOWNLPROT-DOWNLOADTYPE = C_DOWNL_PLANNED_ORDERS.

  YCLOIDOWNLPROT-IN_PROGRESS  = CLOI_TRUE.

* insert or update entry (if entry already exists)

  MODIFY YCLOIDOWNLPROT.

  COMMIT WORK.

  CLEAR CREATED_MASTERIDOCS_PLO.

  EXPORT CREATED_MASTERIDOCS_PLO TO MEMORY ID 'YLOI001'.

  EXPORT YCLOIDOWNLPROT-COUNTER TO MEMORY ID 'YBCALE_PLAF_COUNTER'.

* END OF INSERTION DS001

  IF NO_SEL = CLOI_TRUE.

    CLEAR T_MATWRK_KEY. REFRESH T_MATWRK_KEY.

    LOOP AT MATNR_GL.

      T_MATWRK_KEY-MATNR = MATNR_GL-LOW.

      READ TABLE WERKS_GL  INDEX SY-TABIX.

      T_MATWRK_KEY-WERKS  = WERKS_GL-LOW.

      APPEND T_MATWRK_KEY.

    ENDLOOP.

    SORT T_MATWRK_KEY BY MATNR WERKS.

    DELETE ADJACENT DUPLICATES FROM T_MATWRK_KEY.

* delete duplicate duplicates from ranges table. Therfore sort by LOW

* (HIGH is not used in this case).

    SORT MATNR_GL BY LOW.

    DELETE ADJACENT DUPLICATES FROM MATNR_GL.

    SORT WERKS_GL BY LOW.

    DELETE ADJACENT DUPLICATES FROM WERKS_GL.

  ENDIF.

*MOD-001

*MOD-001

  DATA: ITAB_MATNR TYPE ZZZZ_XREF_DATA OCCURS 0.

  DATA: L_WA_MATNR TYPE ZZZZ_XREF_DATA.

  DATA: L_WA_MATNR_VALUE TYPE Z_IN_VALUE.

  IF NOT MATNR_GL[] IS INITIAL.

*    IF MATNR_EU[] IS INITIAL.

*      SELECT trans_id in_value out_value

         SELECT *

         FROM zzzz_xref_data

         APPENDING TABLE ITAB_MATNR

         WHERE trans_id = 'ZELCUSMATLOOKUP' AND

               ( in_value IN MATNR_GL OR

                 out_value IN MATNR_GL ).

      CHECK SY-SUBRC = 0.

*     SELECT *

*     INTO TABLE ITAB_MATNR

*     FROM ZZZZ_XREF_DATA.

*     CHECK SY-SUBRC = 0.

      LOOP AT ITAB_MATNR INTO L_WA_MATNR.

        L_WA_MATNR_VALUE = L_WA_MATNR-OUT_VALUE.

        MATNR_GL-LOW = L_WA_MATNR_VALUE.

        MATNR_GL-SIGN = 'I'.

        MATNR_GL-OPTION = 'EQ'.

        APPEND MATNR_GL.

      ENDLOOP.

      CLEAR: ITAB_MATNR, L_WA_MATNR.

*    ENDIF.

  ENDIF.

*MOD-002

*MOD-002

 IF NOT MATNR_EU[] IS INITIAL.

*      SELECT trans_id in_value out_value

         SELECT *

         FROM zzzz_xref_data

         APPENDING TABLE ITAB_MATNR

         WHERE trans_id = 'ZELCUSMATLOOKUP' AND

               ( in_value IN MATNR_EU OR

                 out_value IN MATNR_EU ).

      CHECK SY-SUBRC = 0.

*     SELECT *

*     INTO TABLE ITAB_MATNR

*     FROM ZZZZ_XREF_DATA.

*     CHECK SY-SUBRC = 0.

      LOOP AT ITAB_MATNR INTO L_WA_MATNR.

        L_WA_MATNR_VALUE = L_WA_MATNR-OUT_VALUE.

        MATNR_GL-LOW = L_WA_MATNR_VALUE.

        MATNR_GL-SIGN = 'I'.

        MATNR_GL-OPTION = 'EQ'.

        APPEND MATNR_GL.

      ENDLOOP.

      CLEAR: ITAB_MATNR, L_WA_MATNR.

 ENDIF.

*MOD-002

* APPEND MATNR_EU TO MATNR_GL.

*MOD-002

*    DATA: ITAB_MATNR TYPE ZZZZ_XREF_DATA OCCURS 0.

*    DATA: L_WA_MATNR TYPE ZZZZ_XREF_DATA.

*    DATA: L_WA_MATNR_VALUE TYPE Z_IN_VALUE.

*    IF MATNR_GL[] IS INITIAL.

*      SELECT *

*      INTO TABLE ITAB_MATNR

*      FROM ZZZZ_XREF_DATA.

*      CHECK SY-SUBRC = 0.

*      LOOP AT ITAB_MATNR INTO L_WA_MATNR.

*        L_WA_MATNR_VALUE = L_WA_MATNR-IN_VALUE.

*        MATNR_GL-SIGN = 'I'.

*        MATNR_GL-OPTION = 'EQ'.

*        MATNR_GL-LOW = L_WA_MATNR_VALUE.

*        APPEND MATNR_GL.

*      ENDLOOP.

*      CLEAR: ITAB_MATNR, L_WA_MATNR.

*    ENDIF.

*MOD-002

* delete duplicate duplicates from ranges table. Therfore sort by LOW

* (HIGH is not used in this case).

  SORT MATNR_GL BY LOW.

  DELETE ADJACENT DUPLICATES FROM MATNR_GL.

  SORT WERKS_GL BY LOW.

  DELETE ADJACENT DUPLICATES FROM WERKS_GL.

*MOD-001

*MOD-001

*  IF sscrfields-ucomm = 'ONLI'.

  PERFORM DATA_SELECTION.

*  ENDIF.                               "// sscrfields-ucomm = 'ONLI'.

END-OF-SELECTION.

* BEGIN OF INSERTION DS001

* update the entry again to notify that program is finished

  IMPORT CREATED_MASTERIDOCS_PLO FROM MEMORY ID 'YLOI001'.

  YCLOIDOWNLPROT-END_DATE       = SY-DATUM.

  YCLOIDOWNLPROT-END_TIME       = SY-UZEIT.

  YCLOIDOWNLPROT-IDOCS_SELECTED = CREATED_MASTERIDOCS_PLO.

  YCLOIDOWNLPROT-IN_PROGRESS    = CLOI_FALSE.

  YCLOIDOWNLPROT-COUNTER        = YCLOIDOWNLPROT-COUNTER + 1.

* insert or update entry (dependant if entry already exists)

  MODIFY YCLOIDOWNLPROT.

  COMMIT WORK.

* MESSAGE I967(Z001) wITH CREATED_MASTERIDOCS_PLO.

* END OF INSERTION DS001

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

*&      Form  DATA_SELECTION

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

FORM DATA_SELECTION.

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

* Performs the steps to select the planned orders, the corresponding

* reservations and capacity requirements records and calls up the

* function module to create the planned order IDOCs

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

*  -->  DATE_FR   Planning period start

*  -->  DATE_TO   Planning period end

*  -->  DISPO_GL  Global selection: MRP controller

*  -->  MATNR_GL  Global selection: Material

*  -->  ARBPL_GL  Global selection: Work center

*  -->  WERKS_GL  Global selection: Plant

*  -->  PLSCN     Global selection: Planning scenario

*  -->  DISPO_PL  Local selection: MRP controller

*  -->  MATNR_PL  Local selection: Material

*  -->  ARBPL_PL  Local selection: Work center

*  -->  WERKS_PL  Local selection: Plant

*  <--  PLAFX     Selected planned orders

*  <--  KBEDX     Capacity requirements records

*  <--  KBKOX     Header for KBEDs

*  <--  KBEZX     Add. data for KBED

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

*................  Definition of local data  ..........................*

  DATA:                                "INSERT

          SDATA_TEMP   LIKE EDIDD-SDATA,                         "INSERT

          E1PLAFL_REC  LIKE E1PLAFL.   "INSERT

*......................................................................*

*>> Check the existance of global parameters

  IF DISPO_GL[] IS INITIAL AND

     MATNR_GL[] IS INITIAL AND

     ARBPL_GL[] IS INITIAL AND

     WERKS_GL[] IS INITIAL.

    GL_INITIAL = 'X'.

  ELSE.

    CLEAR GL_INITIAL.

  ENDIF.

*>> Check existance of local parameters

  IF DISPO_PL[] IS INITIAL AND

     MATNR_PL[] IS INITIAL AND

     ARBPL_PL[] IS INITIAL AND

     WERKS_PL[] IS INITIAL.

    PL_INITIAL = 'X'.

  ELSE.

    CLEAR PL_INITIAL.

  ENDIF.

  DATA: RETURN TYPE BAPIRETURN,

        L_MATNR TYPE ZZZZ_XREF_DATA-IN_VALUE,

        L_MATNR1 TYPE ZZZZ_XREF_DATA-OUT_VALUE.

  DATA: L_WA_PLAFX TYPE PLAF.

*>> Switch PLSCN in Ranges-Table

* if not plscn is initial.

  PLSCN_RA-LOW = PLSCN.

  PLSCN_RA-SIGN = 'I'.

  PLSCN_RA-OPTION = 'EQ'.

  APPEND PLSCN_RA.

* endif.

*>> Read the cutomizing table for planned order search in the case of

*>> work center input

  SELECT SINGLE VERF_ARBPL FROM TCLOI5 INTO VERF_ARBPL

         WHERE LOGSYS = OPT_SYS.

*>> Select the planned orders

  IF PL_INITIAL IS INITIAL OR GL_INITIAL IS INITIAL.

    IF PL_INITIAL IS INITIAL.

      IF DATE_FR IS INITIAL OR

         DATE_TO IS INITIAL.

        CALL FUNCTION 'CLOI_PLANNED_ORDER_READ'

             EXPORTING

*                DATE_FROM_2  = DATE_FR

*                DATE_TO_2    = DATE_TO

                  VERF_ARBPL   = VERF_ARBPL

             TABLES

*               dispo       = dispo_gl

*               matnr       = matnr_gl

*               arbpl       = arbpl_gl

*               werks       = werks_gl

*               plscn       = plscn_ra

                  DISPO2      = DISPO_PL

                  MATNR2      = MATNR_PL

                  ARBPL2      = ARBPL_PL

                  WERKS2      = WERKS_PL

                  PLSCN2      = PLSCN_RA

                  PLAFX       = PLAFX

             EXCEPTIONS

                  NOT_FOUND   = 1.

        LOOP AT PLAFX INTO L_WA_PLAFX.

          L_MATNR = L_WA_PLAFX-MATNR.

*         L_MATNR1 = L_WA_PLAFX-MATNR.

          SELECT single in_value out_value

          into (l_matnr, l_matnr1)

          FROM zzzz_xref_data

          WHERE trans_id = 'ZELCUSMATLOOKUP' AND

                  out_value = l_wa_plafx-matnr.

*MDO-002

*        CALL FUNCTION 'Z_XREF_LOOKUP'

*             EXPORTING

*                  TRANSID  = 'ZELCUSMATLOOKUP'

*                  INVALUE  = L_MATNR

*             IMPORTING

*                  OUTVALUE = L_MATNR1

*                  RETURN   = RETURN.

*MOD-002

          L_WA_PLAFX-MATNR = L_MATNR.

          MODIFY PLAFX FROM L_WA_PLAFX TRANSPORTING MATNR.

        ENDLOOP.

      ELSE.

        CALL FUNCTION 'CLOI_PLANNED_ORDER_READ'

             EXPORTING

                DATE_FROM_2  = DATE_FR

                DATE_TO_2    = DATE_TO

                  VERF_ARBPL   = VERF_ARBPL

             TABLES

*               dispo       = dispo_gl

*               matnr       = matnr_gl

*               arbpl       = arbpl_gl

*               werks       = werks_gl

*               plscn       = plscn_ra

                  DISPO2      = DISPO_PL

                  MATNR2      = MATNR_PL

                  ARBPL2      = ARBPL_PL

                  WERKS2      = WERKS_PL

                  PLSCN2      = PLSCN_RA

                  PLAFX       = PLAFX

             EXCEPTIONS

                  NOT_FOUND   = 1.

        LOOP AT PLAFX INTO L_WA_PLAFX.

          L_MATNR = L_WA_PLAFX-MATNR.

          SELECT single in_value out_value

          into (l_matnr, l_matnr1)

          FROM zzzz_xref_data

          WHERE trans_id = 'ZELCUSMATLOOKUP' AND

                  out_value = l_wa_plafx-matnr.

          L_WA_PLAFX-MATNR = L_MATNR.

          MODIFY PLAFX FROM L_WA_PLAFX TRANSPORTING MATNR.

        ENDLOOP.

      ENDIF.

    ENDIF.

    IF GL_INITIAL IS INITIAL.

      IF DATE_FR IS INITIAL OR

         DATE_TO IS INITIAL.

        CALL FUNCTION 'CLOI_PLANNED_ORDER_READ'

             EXPORTING

*                DATE_FROM    = DATE_FR

*                DATE_TO      = DATE_TO

                  VERF_ARBPL   = VERF_ARBPL

             TABLES

                  DISPO       = DISPO_GL

                  MATNR       = MATNR_GL

                  ARBPL       = ARBPL_GL

                  WERKS       = WERKS_GL

                  PLSCN       = PLSCN_RA

*                dispo2      = dispo_pl

*                matnr2      = matnr_pl

*                arbpl2      = arbpl_pl

*                werks2      = werks_pl

*                plscn2      = plscn_ra

                  PLAFX       = PLAFX

             EXCEPTIONS

                  NOT_FOUND   = 1.

        LOOP AT PLAFX INTO L_WA_PLAFX.

          L_MATNR = L_WA_PLAFX-MATNR.

          SELECT single in_value out_value

                 into (l_matnr, l_matnr1)

                 FROM zzzz_xref_data

                 WHERE trans_id = 'ZELCUSMATLOOKUP' AND

                         out_value = l_wa_plafx-matnr.

          L_WA_PLAFX-MATNR = L_MATNR.

          MODIFY PLAFX FROM L_WA_PLAFX TRANSPORTING MATNR.

        ENDLOOP.

      ELSE.

        CALL FUNCTION 'CLOI_PLANNED_ORDER_READ'

               EXPORTING

                  DATE_FROM    = DATE_FR

                  DATE_TO      = DATE_TO

                    VERF_ARBPL   = VERF_ARBPL

               TABLES

                    DISPO       = DISPO_GL

                    MATNR       = MATNR_GL

                    ARBPL       = ARBPL_GL

                    WERKS       = WERKS_GL

                    PLSCN       = PLSCN_RA

*                dispo2      = dispo_pl

*                matnr2      = matnr_pl

*                arbpl2      = arbpl_pl

*                werks2      = werks_pl

*                plscn2      = plscn_ra

                    PLAFX       = PLAFX

               EXCEPTIONS

                    NOT_FOUND   = 1.

        LOOP AT PLAFX INTO L_WA_PLAFX.

          L_MATNR = L_WA_PLAFX-MATNR.

          SELECT single in_value out_value

                 into (l_matnr, l_matnr1)

                 FROM zzzz_xref_data

                 WHERE trans_id = 'ZELCUSMATLOOKUP' AND

                         out_value = l_wa_plafx-matnr.

          L_WA_PLAFX-MATNR = L_MATNR.

          MODIFY PLAFX FROM L_WA_PLAFX TRANSPORTING MATNR.

        ENDLOOP.

      ENDIF.

    ENDIF.

*MOD-001

** BEGIN OF INSERTION DS001

** delete all order which do not have the order type LA

*    DELETE PLAFX WHERE PAART NE 'LA'.

** END OF INSERTION DS001

*MOD-001

* If NO_SEL is set delete all entries from PLAFX that should not be send

* MK 4.0C

    IF NO_SEL = CLOI_TRUE AND NOT T_MATWRK_KEY[] IS INITIAL.

      LOOP AT PLAFX.

        READ TABLE T_MATWRK_KEY WITH KEY

                               MATNR = PLAFX-MATNR

                               WERKS = PLAFX-PLWRK BINARY SEARCH.

        IF SY-SUBRC <> 0.

          DELETE PLAFX.

        ENDIF.

      ENDLOOP.

    ENDIF.

    IF NOT PLAFX[] IS INITIAL.

* Is segment active ?

      CALL FUNCTION 'IDOC_REDUCTION_SEGMENT_TEST'

           EXPORTING

                MESSAGE_TYPE = MESTYP

                SEGMENT_TYPE = C_SEGNAM_E1RESBL

           IMPORTING

                ACTIVE       = ACTIVE_FLAG

           EXCEPTIONS

                OTHERS       = 1.

      IF ACTIVE_FLAG = C_TRUE.

*>> Select the reservations

        CALL FUNCTION 'CLOI_RESB_READ'

             TABLES

                  PLAFX      = PLAFX

                  RESBX      = RESBX

             EXCEPTIONS

                  NOT_FOUND  = 1

                  WRONG_CALL = 2.

      ENDIF.

* Test, if the fields gltrs, gluzs, gstrs, gsuzs, plnal,        "INSERT

* plnnr or plnty in the segment e1plafl are active              "INSERT

      CLEAR SDATA_TEMP.                "INSERT

      CLEAR E1PLAFL_REC.               "INSERT

      SDATA_TEMP = E1PLAFL_REC.        "INSERT

      CALL FUNCTION 'IDOC_REDUCTION_FIELD_REDUCE'               "INSERT

             EXPORTING                   "INSERT

                  MESSAGE_TYPE = MESTYP  "INSERT

                SEGMENT_TYPE = C_SEGNAM_E1PLAFL                 "INSERT

                SEGMENT_DATA = SDATA_TEMP                       "INSERT

                  EMPTY_SYMBOL = '1'     "INSERT

             IMPORTING                   "INSERT

                SEGMENT_DATA = SDATA_TEMP.                      "INSERT

      MOVE SDATA_TEMP TO E1PLAFL_REC.   "INSERT

* Is segment active ?

      CALL FUNCTION 'IDOC_REDUCTION_SEGMENT_TEST'

           EXPORTING

                MESSAGE_TYPE = MESTYP

                SEGMENT_TYPE = C_SEGNAM_E1PLOPL

           IMPORTING

                ACTIVE       = ACTIVE_FLAG

           EXCEPTIONS

                OTHERS       = 1.

      IF ACTIVE_FLAG = C_TRUE.

* BEGIN OF DELETION DS001

* Selection of capacity requirements is not necessary

*     E1PLAFL_REC-GLTRS IS INITIAL OR   "INSERT

*     E1PLAFL_REC-GLUZS IS INITIAL OR   "INSERT

*     E1PLAFL_REC-GSTRS IS INITIAL OR   "INSERT

*     E1PLAFL_REC-GSUZS IS INITIAL OR   "INSERT

*     E1PLAFL_REC-PLNAL IS INITIAL OR   "INSERT

*     E1PLAFL_REC-PLNNR IS INITIAL OR   "INSERT

*     E1PLAFL_REC-PLNTY IS INITIAL.     "INSERT

* END OF DELETION DS001

*>> Select the capacity requirements records

        CALL FUNCTION 'CLOI_KBED_READ'

             TABLES

                  PLAFX = PLAFX

                  KBEDX = KBEDX

                  KBKOX = KBKOX

                  KBEZX = KBEZX.

      ENDIF.

* Parallel >>>>>>>>>>>>>>>>

      IF RFCGR <> SPACE.

        H_PARALLEL = C_TRUE.

      ELSE.

        H_PARALLEL = SPACE.

      ENDIF.

* Parallel <<<<<<<<<<<<<<<<

* Parallel >>>>>>>>>>>>>>>>

      IF H_PARALLEL = C_TRUE.

        CALL FUNCTION 'SPBT_INITIALIZE'

             EXPORTING

                  GROUP_NAME                   = RFCGR

             EXCEPTIONS

                  INVALID_GROUP_NAME           = 1

                  INTERNAL_ERROR               = 2

                  PBT_ENV_ALREADY_INITIALIZED  = 3

                  CURRENTLY_NO_RESOURCES_AVAIL = 4

                  NO_PBT_RESOURCES_FOUND       = 5

                  OTHERS                       = 6.

        IF SY-SUBRC = 1 OR SY-SUBRC = 2 OR SY-SUBRC = 5 OR SY-SUBRC = 6.

          H_PARALLEL = SPACE.

        ENDIF.

      ENDIF.

* Parallel <<<<<<<<<<<<<<<<

* Parallel >>>>>>>>>>>>>>>>

      IF H_PARALLEL = SPACE.

* Parallel <<<<<<<<<<<<<<<<

*>> Create Master IDOC

        CALL FUNCTION 'CLOI_MASTERIDOC_CREATE_LOIPLO'

             EXPORTING

                  OPT_SYS      = OPT_SYS

                  MESSAGE_TYPE = MESTYP

             TABLES

                  PLAFX        = PLAFX

                  KBEDX        = KBEDX

                  KBKOX        = KBKOX

                  KBEZX        = KBEZX

                  RESBX        = RESBX.

* Parallel >>>>>>>>>>>>>>>>

      ELSE.

        LOOP AT PLAFX.

          T_PLAFKEYPACK = PLAFX.

          APPEND T_PLAFKEYPACK.

          ADD 1 TO H_COUNTER.

*         ADD 1 TO created_master_idocs.

          IF H_COUNTER >= PSIZE.

            CALL FUNCTION 'CLOI_MASTERIDOC_CREATE_LOIPLO'

                STARTING NEW TASK MESTYP

                DESTINATION IN GROUP RFCGR

                EXPORTING

                     OPT_SYS      = OPT_SYS

                     MESSAGE_TYPE = MESTYP

                     SUPPRESS_PROGRESS_INDICATOR = C_TRUE

                TABLES

                     PLAFX        = T_PLAFKEYPACK

                     KBEDX        = KBEDX

                     KBKOX        = KBKOX

                     KBEZX        = KBEZX

                     RESBX        = RESBX

            EXCEPTIONS

                 RESOURCE_FAILURE = 01.

            IF SY-SUBRC <> 0.

              CALL FUNCTION 'CLOI_MASTERIDOC_CREATE_LOIPLO'

                   EXPORTING

                        OPT_SYS      = OPT_SYS

                        MESSAGE_TYPE = MESTYP

                   TABLES

                        PLAFX        = T_PLAFKEYPACK

                        KBEDX        = KBEDX

                        KBKOX        = KBKOX

                        KBEZX        = KBEZX

                        RESBX        = RESBX.

            ENDIF.

            H_COUNTER = 0.

            CLEAR T_PLAFKEYPACK.

            REFRESH T_PLAFKEYPACK.

          ENDIF.

        ENDLOOP.

        IF H_COUNTER > 0.

          CALL FUNCTION 'CLOI_MASTERIDOC_CREATE_LOIPLO'

              STARTING NEW TASK MESTYP

              DESTINATION IN GROUP RFCGR

              EXPORTING

                   OPT_SYS      = OPT_SYS

                   MESSAGE_TYPE = MESTYP

                   SUPPRESS_PROGRESS_INDICATOR = C_TRUE

              TABLES

                   PLAFX        = T_PLAFKEYPACK

                   KBEDX        = KBEDX

                   KBKOX        = KBKOX

                   KBEZX        = KBEZX

                   RESBX        = RESBX

          EXCEPTIONS

               RESOURCE_FAILURE = 01.

          IF SY-SUBRC <> 0.

            CALL FUNCTION 'CLOI_MASTERIDOC_CREATE_LOIPLO'

                 EXPORTING

                      OPT_SYS      = OPT_SYS

                      MESSAGE_TYPE = MESTYP

                 TABLES

                      PLAFX        = T_PLAFKEYPACK

                      KBEDX        = KBEDX

                      KBKOX        = KBKOX

                      KBEZX        = KBEZX

                      RESBX        = RESBX.

          ENDIF.

          H_COUNTER = 0.

          CLEAR T_PLAFKEYPACK.

          REFRESH T_PLAFKEYPACK.

        ENDIF.

      ENDIF.

* Parallel <<<<<<<<<<<<<<<<

    ENDIF.                             "// not plafx[] is initial

  ENDIF.                               "// gl_initial = 0 ...

ENDFORM.                               " DATA_SELECTION
 
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> PP All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.