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

Explode Equipment Record and Pass Warranty Data



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



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Mon Sep 08, 2008 4:22 pm    Post subject: Explode Equipment Record and Pass Warranty Data Reply with quote

Explode Equipment Record and Pass Warranty Data selectively to Sub-Items

Code:
REPORT ZEQUIPEX MESSAGE-ID ZZ NO STANDARD PAGE HEADING
                LINE-SIZE 80 LINE-COUNT 65.
TABLES: EQUI, BGMK.
PARAMETERS: EQUIPNO LIKE EQUI-EQUNR OBLIGATORY.
*Select Text 'E' Equipment Number
PARAMETERS: EQUIPDT LIKE EQUZ-DATBI DEFAULT SY-DATUM.
*Select Text 'E' Equipment Number

DATA: BEGIN OF EQUITAB OCCURS 100.
        INCLUDE STRUCTURE V_EQUI.
DATA: END OF EQUITAB.

DATA: BEGIN OF TAB OCCURS 100,
      ITEMNO TYPE P,
      LEVELNO TYPE P,
      EQUIPNO LIKE V_EQUI-EQUNR,
      ALREADY-EXPLODED,
      END OF TAB.

DATA: BEGIN OF TAB2 OCCURS 100.
        INCLUDE STRUCTURE TAB.
DATA: END OF TAB2.
DATA: BEGIN OF PROCESSTAB OCCURS 100,
        EQUIPNO LIKE TAB-EQUIPNO,
      END OF PROCESSTAB.
DATA: BEGIN OF ORIGEQUI.
        INCLUDE STRUCTURE EQUI.
DATA: END OF ORIGEQUI.

DATA: LEVELNO LIKE TAB-LEVELNO VALUE 0.
DATA: ITEMNO  LIKE TAB-ITEMNO VALUE 0.
DATA: EQUIP LIKE EQUIPNO.
DATA: EXPLODE-AGAIN VALUE 'Y'.
DATA: NUMLINES TYPE P.
DATA: MARKFIELD.
DATA: REC_COUNT TYPE P.
DATA: REC_PROCESSED LIKE REC_COUNT.
DATA: REC_ERRORS LIKE REC_COUNT.
DATA: SESNAME(12) VALUE '            '.
DATA: SESNAME_ERR(12) VALUE 'WARRANTY'.
DATA: TMODE_BD VALUE ' '.
DATA: TMODE_CT VALUE 'X'.
DATA: DSPL-DATE(10).
DATA: TCODE(4),
      BAD-RECORD(1)  VALUE 'N',
      UPMODE VALUE   'N',
      COMMIT_FREQUENCY TYPE I VALUE 100,
      COMMIT_CHECK     TYPE I,
      LOAD_MODE_BD     TYPE I VALUE 1,
      LOAD_MODE_CT     TYPE I VALUE 2,
      LOAD_MODE        TYPE N.
DATA: BEGIN OF INREC.
      INCLUDE STRUCTURE TAB.
DATA: END OF INREC.
DATA: SHOWAUDT.

DATA: BEGIN OF COUNTS OCCURS 200,
      TYPE(30),
      INPUT LIKE REC_COUNT,
      GOOD LIKE REC_COUNT,
      BAD LIKE REC_COUNT,
        END OF COUNTS.
SELECTION-SCREEN SKIP.
PARAMETERS:
  UPMODE_N             RADIOBUTTON GROUP UPMD,
*SELTEXT*E*  "Screen MODE - See NOTHING"
  UPMODE_A             RADIOBUTTON GROUP UPMD,
*SELTEXT*E*  "Screen MODE - See ALL"
  UPMODE_E DEFAULT 'X' RADIOBUTTON GROUP UPMD.
*SELTEXT*E*  "Screen MODE - ERRORS Only"

DATA: BEGIN OF BDC_TAB OCCURS 10.
        INCLUDE STRUCTURE BDCDATA.
DATA: END OF BDC_TAB.

AT SELECTION-SCREEN.
  IF SESNAME IS INITIAL AND TMODE_BD EQ 'X'.
    MESSAGE E999 WITH
            'BDC Flag set but no BDC Session Name provided.'.
    EXIT.
  ENDIF.
  IF SESNAME GT SPACE AND TMODE_CT EQ 'X'.
    CLEAR SESNAME.
    MESSAGE W999 WITH
            'Call Trans Flag set.  BDC Session Name ignored.'.
    EXIT.
  ENDIF.

START-OF-SELECTION.
*---------------------------------------------------------------------*
  PERFORM CHECK-TCODE-AUTHORITY USING 'SE38'.
  IF UPMODE_A EQ 'X'.
    UPMODE = 'A'.             " If CALL Transaction - Show All Screens
  ELSEIF UPMODE_N EQ 'X'.
    UPMODE = 'N'.             "                     - Show Nothing
  ELSEIF UPMODE_E EQ 'X'.
    UPMODE = 'E'.             "                     - Show Only Errors
  ENDIF.
  if not sy-batch is initial.
    move 'N' to upmode.
  endif.
  if sesname is initial.
    load_mode = load_mode_ct.
  else.
    load_mode = load_mode_bd.
  endif.

  PERFORM CREATE-REPORT.

*---------------------------------------------------------------------*
*       FORM CREATE-REPORT                                            *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM CREATE-REPORT.
  SELECT SINGLE * FROM EQUI WHERE EQUNR EQ EQUIPNO.
  IF SY-SUBRC NE 0.
    MESSAGE E999 WITH 'Equipment rec not Found for' EQUIPNO.
  ELSE.
    MOVE EQUI TO ORIGEQUI.
    IF EQUI-GWLEN IS INITIAL.
      SELECT SINGLE * FROM BGMK WHERE MGANR EQ EQUI-MGANR.
      IF SY-SUBRC NE 0.
        MESSAGE E999 WITH 'Warranty not set for Equipment Rec' EQUIPNO.
      ENDIF.
    ENDIF.
  ENDIF.
  REFRESH TAB.
  CLEAR TAB.
  MOVE EQUIPNO TO TAB-EQUIPNO.
  MOVE 1       TO TAB-ITEMNO.
  MOVE 1       TO TAB-LEVELNO.
  MOVE 'N'     TO TAB-ALREADY-EXPLODED.
  APPEND TAB.

  WHILE EXPLODE-AGAIN EQ 'Y'.
    REFRESH TAB2.
    MOVE 'N' TO EXPLODE-AGAIN.
    LOOP AT TAB.
      REFRESH EQUITAB.
      IF TAB-ALREADY-EXPLODED EQ 'N'.
        CALL FUNCTION 'EQUIPMENT_SUCCESSORS'
             EXPORTING
                  EQUI_NO         = TAB-EQUIPNO
                  READING_DATE    = EQUIPDT
             TABLES
                  EQUI_TAB        = EQUITAB
             EXCEPTIONS
                  NO_SUCCESSORS   = 1
                  SUCC_READ_ERROR = 2
                  OTHERS          = 3.
        DESCRIBE TABLE EQUITAB LINES NUMLINES.
        IF NUMLINES NE 0.
          MOVE 'Y' TO EXPLODE-AGAIN.
        ENDIF.
      ENDIF.
      CLEAR TAB2.
      MOVE-CORRESPONDING TAB TO TAB2.
      TAB2-ITEMNO = TAB2-ITEMNO + 1.
      MOVE 'Y'               TO TAB2-ALREADY-EXPLODED.
      APPEND TAB2.
      LOOP AT EQUITAB.
        CLEAR TAB2.
        MOVE-CORRESPONDING TAB TO TAB2.
        MOVE EQUITAB-EQUNR TO TAB2-EQUIPNO.
        TAB2-LEVELNO = TAB2-LEVELNO + 1.
        ITEMNO = ITEMNO + 1.
        MOVE ITEMNO  TO TAB2-ITEMNO.
        MOVE 'N'     TO TAB2-ALREADY-EXPLODED.
        APPEND TAB2.
      ENDLOOP.
    ENDLOOP.
    REFRESH TAB.
    LOOP AT TAB2.
      MOVE-CORRESPONDING TAB2 TO TAB.
      APPEND TAB.
    ENDLOOP.
  ENDWHILE.

  LOOP AT TAB2.
    WRITE MARKFIELD AS CHECKBOX.
    DO TAB2-LEVELNO TIMES.
      WRITE '   '.
    ENDDO.
    WRITE  TAB2-EQUIPNO.
    SELECT SINGLE * FROM EQUI WHERE EQUNR EQ TAB2-EQUIPNO.
    IF SY-SUBRC EQ 0.
      WRITE: EQUI-MGANR, EQUI-GWLDT, EQUI-GWLEN.
*     select single * from bgmk where mganr eq equi-mganr.
*     if sy-subrc eq 0.
*       write: bgmk-datab, 'thru', bgmk-datbi.
*     endif.
    ENDIF.
    HIDE TAB2-EQUIPNO.
    SKIP.
  ENDLOOP.
  SET PF-STATUS 'BASE'.

ENDFORM.
*---------------------------------------------------------------------*
*       FORM MAINLINE_INPUT                                           *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM MAINLINE_INPUT.
  if load_mode eq load_mode_bd.
    perFORM open_bdc_session using sesname.
  endif.

  PERFORM PROCESS_DATA.

  if not sesname is INITIAL.
    perform close_bdc_session.
  endif.

  NEW-PAGE.
  ULINE.
  IF LOAD_MODE EQ LOAD_MODE_BD.
    WRITE: / 'Data loaded into BDC Session'.
  ELSE.
    WRITE: / 'Data loaded using Call Transaction'.
  ENDIF.
  ULINE.
  WRITE: / REC_COUNT,    'Generated SAP Change records'.
  WRITE: / REC_PROCESSED,    'Records Processed'.
  WRITE: / REC_ERRORS,       'Records processed in ERROR'.
  IF LOAD_MODE EQ LOAD_MODE_BD.
    WRITE: / 'MUST MANUALLY Process Batch Input Session=', SESNAME.
  ENDIF.
  IF REC_ERRORS GT 0.
    WRITE: / '****************************************'.
    WRITE: / 'Not ALL of the Data Process Successfully'.
    WRITE: / 'You can MANUALLY Process Batch Input Session=',
              SESNAME_ERR.
    WRITE: / 'To Update the Remaining Unprocessed Data'.
    WRITE: / '****************************************'.
  ENDIF.
  ULINE.
ENDFORM.

*---------------------------------------------------------------------*
*       FORM PROCESS_DATA                                             *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM PROCESS_DATA.
  DATA:
  COMMIT_CHECK TYPE I.
  LOOP AT PROCESSTAB WHERE EQUIPNO NE EQUIPNO.
    PERFORM PROCESS-REC.
    COMMIT_CHECK = REC_COUNT MOD COMMIT_FREQUENCY.
    IF COMMIT_CHECK EQ 0.
      COMMIT WORK.
    ENDIF.
  ENDLOOP.
ENDFORM.
*---------------------------------------------------------------------*
*       FORM PROCESS-REC                                              *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM PROCESS-REC.
  ADD 1 TO REC_COUNT.
  MOVE 'IE02'    TO TCODE.
  PERFORM GENERATE_BDC.
  PERFORM PROCESS_BDC_DATA.
  IF LOAD_MODE EQ LOAD_MODE_CT.
    IF SY-SUBRC NE 0.
      WRITE: / 'Did not Process in BDC',
               'Equipment Number', PROCESSTAB-EQUIPNO.
      PERFORM WRITE_TRANSACTION_MSG.
      PERFORM PROCES_CALL_TRANSACTION_ERROR.
      ADD 1 TO REC_ERRORS.
    ELSE.
      PERFORM WRITE_TRANSACTION_MSG.
      ADD 1 TO REC_PROCESSED.
    ENDIF.
  ENDIF.
ENDFORM.
*---------------------------------------------------------------------*
*       FORM GENERATE_BDC                                             *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM GENERATE_BDC.
  REFRESH BDC_TAB.
  PERFORM ADD_BDC_SCREEN USING 'SAPMIEQ0' '0100' 'X'.
  PERFORM ADD_BDC_FIELD USING 'RM63E-EQUNR' PROCESSTAB-EQUIPNO.
  PERFORM ADD_BDC_SCREEN USING 'SAPMIEQ0' '0102' 'X'.
  PERFORM ADD_BDC_OKCODE USING 'GARA'.
  PERFORM ADD_BDC_SCREEN USING 'SAPMIEQ0' '0122' 'X'.
  IF ORIGEQUI-GWLDT > '00000000'.
    WRITE ORIGEQUI-GWLDT   TO DSPL-DATE.
    PERFORM ADD_BDC_FIELD USING 'EQUI-GWLDT' DSPL-DATE.
  ENDIF.
  IF ORIGEQUI-GWLEN > '00000000'.
    WRITE ORIGEQUI-GWLEN   TO DSPL-DATE.
    PERFORM ADD_BDC_FIELD USING 'EQUI-GWLEN' DSPL-DATE.
  ENDIF.
* perform add_bdc_field using 'EQUZ-LIZNR' origequi-liznr.
  PERFORM ADD_BDC_FIELD USING 'EQUI-MGANR' ORIGEQUI-MGANR.
  IF ORIGEQUI-AULDT > '00000000'.
    WRITE ORIGEQUI-AULDT   TO DSPL-DATE.
    PERFORM ADD_BDC_FIELD USING 'EQUI-AULDT' DSPL-DATE.
  ENDIF.
  IF ORIGEQUI-INBDT > '00000000'.
    WRITE ORIGEQUI-INBDT   TO DSPL-DATE.
    PERFORM ADD_BDC_FIELD USING 'EQUI-INBDT' DSPL-DATE.
  ENDIF.
  PERFORM ADD_BDC_OKCODE USING '/0  '.
  PERFORM ADD_BDC_SCREEN USING 'SAPMIEQ0' '0122' 'X'.
  PERFORM ADD_BDC_OKCODE USING '/3  '.
  PERFORM ADD_BDC_SCREEN USING 'SAPMIEQ0' '0102' 'X'.
  PERFORM ADD_BDC_OKCODE USING 'BU  '.
ENDFORM.

AT USER-COMMAND.
  CASE SY-UCOMM.
    WHEN 'PROC'.
      REFRESH PROCESSTAB.
      SET PF-STATUS 'PROC'.
      DO.
        CLEAR MARKFIELD.
        READ LINE SY-INDEX FIELD VALUE MARKFIELD.
        IF SY-SUBRC > 0.
          EXIT.
        ENDIF.
        CHECK MARKFIELD NE SPACE.
        MOVE TAB2-EQUIPNO TO PROCESSTAB-EQUIPNO.
        COLLECT PROCESSTAB.
        MODIFY CURRENT LINE
          FIELD VALUE
             MARKFIELD  FROM SPACE.
      ENDDO.
      PERFORM MAINLINE_INPUT.
*     loop at processtab.
*       write: / processtab-equipno.
*     endloop.
    WHEN 'SALL'.
      DO.
        CLEAR MARKFIELD.
        READ LINE SY-INDEX FIELD VALUE MARKFIELD.
        IF SY-SUBRC > 0.
          EXIT.
        ENDIF.
        MODIFY CURRENT LINE
          FIELD VALUE
             MARKFIELD  FROM 'X'.
      ENDDO.
    WHEN 'UALL'.
      DO.
        CLEAR MARKFIELD.
        READ LINE SY-INDEX FIELD VALUE MARKFIELD.
        IF SY-SUBRC > 0.
          EXIT.
        ENDIF.
        MODIFY CURRENT LINE
          FIELD VALUE
             MARKFIELD  FROM SPACE.
      ENDDO.
    WHEN 'REFR'.
      PERFORM CREATE-REPORT.
    WHEN OTHERS.
      SET PF-STATUS 'BASE'.
  ENDCASE.

* Search this include on this forum
  INCLUDE ZCONINC5.
  INCLUDE ZCONINC3.
Back to top
View user's profile Send private message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Mon Sep 08, 2008 4:23 pm    Post subject: Reply with quote

Code:
* Source Name is  ZCONINC5
***INCLUDE ZCONINC5.
* ZCONINC4 & ZCONINC5 are Matched Pairs
* ZCONINC1 & ZCONINC2 are Matched Pairs - ZCONINC4 in imbeded in
* in ZCONINC4 -- ZCONINC5 is imbeded in  ZCONINC2
FORM WRITE_TRANSACTION_MSG.
* Determine Message that happended at Screen Processing Time
  TABLES:
    T100.                              " System messages table
  DATA:
    TEXT(240),
    TEMP-AMOUNT(15).
* Read the error message text line
  SELECT SINGLE * FROM T100
         WHERE SPRSL = SY-LANGU
         AND   ARBGB = SY-MSGID
         AND   MSGNR = SY-MSGNO.
* Move in the specific components of the error message from the
* system variables SY-MSGV1-4.
  IF SY-SUBRC EQ 0.
    CLEAR TEXT.
    MOVE 'Message:' TO TEXT.
    MOVE   T100-TEXT TO TEXT+8.
    REPLACE '&' WITH SY-MSGV1 INTO TEXT.
    REPLACE '&' WITH SY-MSGV2 INTO TEXT.
    REPLACE '&' WITH SY-MSGV3 INTO TEXT.
    REPLACE '&' WITH SY-MSGV4 INTO TEXT.
    CONDENSE TEXT.
    MOVE SY-TVAR1 TO TEXT+100.
    MOVE SY-TVAR2 TO TEXT+120.
    MOVE SY-TVAR3 TO TEXT+140.
    MOVE SY-TVAR4 TO TEXT+160.
    MOVE SY-TVAR5 TO TEXT+180.
    MOVE ',RecNumber=' TO TEXT+201.
    WRITE REC_COUNT  TO TEMP-AMOUNT.
    MOVE TEMP-AMOUNT TO TEXT+212.
    CONDENSE TEXT.
    CLEAR SY-TVAR1.
    CLEAR SY-TVAR2.
    CLEAR SY-TVAR3.
    CLEAR SY-TVAR4.
    CLEAR SY-TVAR5.
    WRITE: / TEXT(132).
  ENDIF.
ENDFORM.
FORM ADD_BDC_SCREEN USING PROGRAM SCREEN IND.
* BDC Screen Information
  CLEAR   BDC_TAB.
  BDC_TAB-PROGRAM  = PROGRAM.          " Program
  BDC_TAB-DYNPRO   = SCREEN.           " and Screen
  BDC_TAB-DYNBEGIN = IND.
  APPEND BDC_TAB.
ENDFORM.
FORM ADD_BDC_FIELD USING FIELD_NAME FIELD_VALUE.
* BDC Field Information
  CLEAR   BDC_TAB.
  IF NOT FIELD_VALUE IS INITIAL OR SY-REPID+2(2) EQ 'PA'
* These programs/types of programs/field need SPACES to be
* a Valid Entry
* IN ALL OTHERS - field is not Needed if SPACES
                                OR SY-REPID+2(3) EQ 'CUS'
                                OR SY-REPID(8) EQ 'ZFUNCLOC'
                                OR FIELD_NAME EQ 'MARC-SERNP'
                                OR FIELD_NAME EQ 'LTAP-NLQNR'
                                OR FIELD_NAME EQ 'RC271-PLNNR'
                                OR FIELD_NAME CS '*PRPS-POSID'
                                OR FIELD_NAME CS 'PRPS-POSID'
                                OR FIELD_NAME CS 'RV02P-KUNDE'
                                OR FIELD_NAME CS 'RM03S-LGORT'
                                OR FIELD_NAME CS 'MCHA-VFDAT'
                                OR FIELD_NAME CS 'PRI_PARAMS'
                                OR FIELD_NAME CS 'REPOS'.
  PERFORM MOV_BDC_FIELD USING FIELD_NAME FIELD_VALUE.
  ENDIF.
ENDFORM.
FORM MOV_BDC_FIELD USING FIELD_NAME FIELD_VALUE.
  BDC_TAB-FNAM     = FIELD_NAME.       " Field Name
  BDC_TAB-FVAL     = FIELD_VALUE.      " and Value
  APPEND BDC_TAB.
ENDFORM.
FORM process_bdc_data.
* Process either BDC or CALL TRANSACTION - depending on
* Specified Options
  IF load_mode eq load_mode_bd.
    CALL FUNCTION 'BDC_INSERT'
         EXPORTING
              TCODE     = TCODE
         TABLES
              DYNPROTAB = BDC_TAB.
  ELSE.
    CALL TRANSACTION TCODE
              USING       BDC_TAB
             UPDATE      'S'
             MODE        UPMODE.
  endif.
ENDFORM.
FORM ADD_BDC_OKCODE USING F_CODE.
* BDC OKCODE Information
  CLEAR   BDC_TAB.
  BDC_TAB-FNAM     = 'BDC_OKCODE'.     "OK-Code
  BDC_TAB-FVAL     = F_CODE.           " and Value
  APPEND BDC_TAB.
ENDFORM.
FORM open_bdc_session using session_name.
* Open BDC Session Name
 CALL FUNCTION 'BDC_OPEN_GROUP'
      EXPORTING
           CLIENT = SY-MANDT
           GROUP  = session_name    "BDC Session Name
           KEEP   = 'X'
           USER   = SY-UNAME.
ENDFORM.
FORM close_bdc_session.
* Close BDC Session Name
  call function 'BDC_CLOSE_GROUP'.
ENDFORM.
FORM proces_call_transaction_error.
* On Rejected CALL TRANSACTION records - move data into a
*  BDC Session - on First Error -- CREATE A SESSION
  if SESNAME is initial.
      perform OPEN_BDC_SESSION using sesname_err.
      sesname = sesname_err.
  endif.
* Write the error transaction BDC data to the error BDC session
  CALL FUNCTION 'BDC_INSERT'
       EXPORTING
            TCODE     = TCODE
       TABLES
            DYNPROTAB = BDC_TAB.
ENDFORM.
*---------------------------------------------------------------------*
*       FORM CHK-PROCESS_BDC_DATA                                     *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  CHK-LIT                                                       *
*  -->  CHK-VAR                                                       *
*---------------------------------------------------------------------*
FORM CHK-PROCESS_BDC_DATA5 USING CHK-LIT CHK-VAR.
* Determine is Transaction has Processed Successfully
  IF load_mode eq LOAD_MODE_CT.
    IF SY-SUBRC NE 0.
      MOVE 'Y' TO BAD-RECORD.
      PERFORM WRITE_TRANSACTION_MSG.
      PERFORM PROCES_CALL_TRANSACTION_ERROR.
      PERFORM ADD-IN-COUNTS USING CHK-LIT 'BAD'.
    ELSE.
      PERFORM ADD-IN-COUNTS USING CHK-LIT 'GOOD'.
      MOVE SY-MSGV1 TO CHK-VAR.
      IF SHOWAUDT EQ 'X'.
        PERFORM WRITE_TRANSACTION_MSG.
      ENDIF.
    ENDIF.
    ENDIF.
  ENDFORM.
*---------------------------------------------------------------------*
*       FORM ADD-IN-COUNTS                                            *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  DESC-LIT                                                      *
*  -->  STATUS-LIT                                                    *
*---------------------------------------------------------------------*
FORM ADD-IN-COUNTS USING DESC-LIT STATUS-LIT.
* Add in Program Counts - Description of Activity is used
*  as a Key to Control Counts
*  WAS DONE THIS WAY - to avoid setting UP all kinds of Unique
*  Counter Fields in each and every Program
  READ TABLE COUNTS WITH KEY DESC-LIT
     BINARY SEARCH.
  IF SY-SUBRC EQ 0.
    IF STATUS-LIT EQ 'INPUT'.
      ADD 1 TO COUNTS-INPUT.
    ENDIF.
    IF STATUS-LIT EQ 'GOOD'.
      ADD 1 TO COUNTS-GOOD.
    ENDIF.
    IF STATUS-LIT EQ 'BAD'.
      ADD 1 TO COUNTS-BAD.
    ENDIF.
    IF STATUS-LIT EQ 'BYPASS'.
      ADD 1 TO COUNTS-BYPASS.
    ENDIF.
    MODIFY COUNTS INDEX SY-TABIX.
  ELSE.
    CLEAR COUNTS.
    MOVE DESC-LIT TO COUNTS-TYPE.
    IF STATUS-LIT EQ 'INPUT'.
      ADD 1 TO COUNTS-INPUT.
    ENDIF.
    IF STATUS-LIT EQ 'GOOD'.
      ADD 1 TO COUNTS-GOOD.
    ENDIF.
    IF STATUS-LIT EQ 'BAD'.
      ADD 1 TO COUNTS-BAD.
    ENDIF.
    IF STATUS-LIT EQ 'BYPASS'.
      ADD 1 TO COUNTS-BYPASS.
    ENDIF.
    INSERT COUNTS INDEX SY-TABIX.
  ENDIF.
  IF SY-REPID NE 'ZSDORFP004'.
    if status-lit eq 'BAD'.
      write: / 'Rejected During Processing', desc-lit,
       'Rec Number=', rec_count.
    endif.
  endif.
ENDFORM.
*---------------------------------------------------------------------*
*       FORM WRITE-OUT-COUNTS                                         *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM WRITE-OUT-COUNTS.
  LOOP AT COUNTS.
    if counts-input gt 0.
      WRITE: / COUNTS-INPUT, COUNTS-TYPE, 'Derived Inputs'.
    endif.
    if counts-good gt 0.
      WRITE: / COUNTS-GOOD,  COUNTS-TYPE, 'Processed Succesfully'.
    endif.
    if counts-bad gt 0.
      WRITE: / COUNTS-BAD,  COUNTS-TYPE, 'Rejected During Processing'.
    endif.
    IF COUNTS-BYPASS GT 0.
     WRITE: / COUNTS-BYPASS,  COUNTS-TYPE, 'Bypassed During Processing'.
    endif.
  ENDLOOP.
ENDFORM.
*---------------------------------------------------------------------*
*       FORM SEND-MESSAGE-VIA-ZZMSG                                   *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM SEND-MESSAGE-VIA-ZZMSG.
*tables: zpgm.
*  Following Code - use Function Module or NOT                       *
*                 - comment out one of the Approaches                *
****TO NOT USE FUNCTION MODULE****************************************
  DATA: Z_TMP-COUNT(8) TYPE P.
  IF NOT SY-BATCH IS INITIAL.
    CLEAR ZZMSG_TAB1.
    MOVE SY-UNAME TO ZZMSG_TAB1.
    COLLECT ZZMSG_TAB1.
  ENDIF.
  DESCRIBE TABLE ZZMSG_TAB1 LINES Z_TMP-COUNT.
  CHECK Z_TMP-COUNT > 0.
  DESCRIBE TABLE ZZMSG_TAB2 LINES Z_TMP-COUNT.
  CHECK Z_TMP-COUNT > 0.
  CLEAR ZZMSG_TAB2.
  MOVE 'Above Message occured in Program' TO ZZMSG_TAB2.
  APPEND ZZMSG_TAB2.
  CLEAR ZZMSG_TAB2.
  MOVE SY-REPID                        TO ZZMSG_TAB2.
  APPEND ZZMSG_TAB2.
  CLEAR ZZBIGTXT.
  MOVE 'On System:' TO ZZBIGTXT.
  MOVE SY-SYSID TO ZZBIGTXT+12(3).
  MOVE 'In Client:' TO ZZBIGTXT+20(15).
  WRITE SY-MANDT    TO ZZBIGTXT+45.
  CONDENSE ZZBIGTXT.
  MOVE ZZBIGTXT TO ZZMSG_TAB2.
  APPEND ZZMSG_TAB2.
  CLEAR ZZBIGTXT.
  MOVE 'On Date:' TO ZZBIGTXT.
  WRITE SY-DATUM TO ZZBIGTXT+12(10).
  MOVE 'At:' TO ZZBIGTXT+25(05).
  WRITE SY-UZEIT    TO ZZBIGTXT+45.
  CONDENSE ZZBIGTXT.
  MOVE ZZBIGTXT TO ZZMSG_TAB2.
  APPEND ZZMSG_TAB2.
* select single * from zpgm where pgm eq sy-repid.
*********************************************************************
* Look UP in a NEW TABLE - if Messages from this Program are        *
*   to be Sent to One or More People                                *
*********************************************************************
* if sy-subrc eq 0.
*   if not zpgm-name1 is initial.
*      clear zzmsg_tab1.
*      move zpgm-name1 to  zzmsg_tab1.
*      collect zzmsg_tab1.
*   endif.
*   if not zpgm-name2 is initial.
*      clear zzmsg_tab1.
*      move zpgm-name2 to  zzmsg_tab1.
*      collect zzmsg_tab1.
*   endif.
*   if not zpgm-name3 is initial.
*      clear zzmsg_tab1.
*      move zpgm-name3 to  zzmsg_tab1.
*      collect zzmsg_tab1.
*   endif.
*   if not zpgm-name4 is initial.
*      clear zzmsg_tab1.
*      move zpgm-name4 to  zzmsg_tab1.
*      collect zzmsg_tab1.
*   endif.
*   if not zpgm-name5 is initial.
*      clear zzmsg_tab1.
*      move zpgm-name5 to  zzmsg_tab1.
*      collect zzmsg_tab1.
*   endif.
*   if not zpgm-name6 is initial.
*      clear zzmsg_tab1.
*      move zpgm-name6 to  zzmsg_tab1.
*      collect zzmsg_tab1.
*   endif.
*   if not zpgm-name7 is initial.
*      clear zzmsg_tab1.
*      move zpgm-name7 to  zzmsg_tab1.
*      collect zzmsg_tab1.
*   endif.
*   if not zpgm-name8 is initial.
*      clear zzmsg_tab1.
*      move zpgm-name8 to  zzmsg_tab1.
*      collect zzmsg_tab1.
*   endif.
* endif.
  PERFORM SEND-MSG(ZZMSG)  TABLES ZZMSG_TAB1 ZZMSG_TAB2.
***********************************************************************
****TO USE FUNCTION MODULE*********************************************
* call function 'Z_SEND_MESSAGE'
*     exporting       pgm_id        =  z_pgmid
*                     severity_level = z_severity_level
*     tables          zzmsg_tab1     = zzmsg_tab1
*                     zzmsg_tab2     = zzmsg_tab2.
***********************************************************************
ENDFORM.
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 -> CO 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.