How to print the error records and success records in bdc

how to print the number of error records and success records in bdc

hai,
plz refer this program,
Z_130399130271_A
REPORT Z_130399130271_A
       NO STANDARD PAGE HEADING LINE-SIZE 325.
*INCLUDE YVALIDATE.
*include bdcrecx1.
INCLUDE YINCLUDE399.
DATA ITAB LIKE TABLE OF FILE_TABLE WITH HEADER LINE.
PARAMETERS: DATASET(132) LOWER CASE.
DATA : RC TYPE I,
ERR(40) TYPE C,
SUCCESSCNT TYPE I VALUE 0,
FAILCOUNT TYPE I VALUE 0.
   DO NOT CHANGE - the generated data section - DO NOT CHANGE    ***
  If it is nessesary to change the data section use the rules:
  1.) Each definition of a field exists of two lines
  2.) The first line shows exactly the comment
      '* data element: ' followed with the data element
      which describes the field.
      If you don't have a data element use the
      comment without a data element name
  3.) The second line shows the fieldname of the
      structure, the fieldname must consist of
      a fieldname and optional the character '_' and
      three numbers and the field length in brackets
  4.) Each field must be type C.
Generated data section with specific formatting - DO NOT CHANGE  ***
DATA: BEGIN OF RECORD OCCURS 0,
data element: LIF16
        LIFNR_001(016),
data element: KTOKK
        KTOKK_002(004),
data element: ANRED
        ANRED_003(015),
data element: NAME1_GP
        NAME1_004(035),
data element: SORTL
        SORTL_005(010),
data element: STRAS_GP
        STRAS_006(035),
data element: PFACH
        PFACH_007(010),
data element: ORT01_GP
        ORT01_008(035),
data element: ORT02_GP
        ORT02_009(035),
data element: LAND1_GP
        LAND1_010(003),
data element: REGIO
        REGIO_011(003),
data element: SPRAS
        SPRAS_012(002),
data element: TELF1
        TELF1_013(016),
data element: TELF2
        TELF2_014(016),
data element: BANKS
        BANKS_01_015(003),
data element: BANKK
        BANKL_01_016(015),
data element: BANKN
        BANKN_01_017(018),
      END OF RECORD.
DATA:   BEGIN OF ERRORITAB OCCURS 0,
        LIFNR_001 LIKE LFA1-LIFNR,
        KTOKK_002 LIKE LFA1-KTOKK,
        ANRED_003 LIKE LFA1-ANRED,
        NAME1_004 LIKE LFA1-NAME1,
        SORTL_005 LIKE LFA1-SORTL,
        STRAS_006 LIKE LFA1-STRAS,
        PFACH_007 LIKE LFA1-PFACH,
        ORT01_008 LIKE LFA1-ORT01,
        ORT02_009 LIKE LFA1-ORT02,
        LAND1_010 LIKE LFA1-LAND1,
        REGIO_011 LIKE LFA1-REGIO,
        SPRAS_012 LIKE LFA1-SPRAS,
        TELF1_013 LIKE LFA1-TELF1,
        TELF2_014 LIKE LFA1-TELF2,
        BANKS_01_015 LIKE LFBK-BANKS,
        BANKL_01_016 LIKE LFBK-BANKL,
        BANKN_01_017 LIKE LFBK-BANKN,
        ERRORMSG(60) TYPE C,
        SERIAL TYPE I VALUE '1',
    END OF ERRORITAB.
End generated data section ***
AT SELECTION-SCREEN ON VALUE-REQUEST FOR DATASET.
  CALL FUNCTION 'TMP_GUI_FILE_OPEN_DIALOG'
EXPORTING
    WINDOW_TITLE            = 'select a file '
    DEFAULT_EXTENSION       = 'TXT'
    DEFAULT_FILENAME        = 'ASSIGN5.TXT'
  FILE_FILTER             =
  INIT_DIRECTORY          =
  MULTISELECTION          =
IMPORTING
  RC                      =
    TABLES
      FILE_TABLE              = ITAB
EXCEPTIONS
   CNTL_ERROR              = 1
   OTHERS                  = 2
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  READ TABLE ITAB INDEX 1.
  DATASET = ITAB-FILENAME.
  WRITE DATASET.
START-OF-SELECTION.
*perform open_dataset using dataset.
*perform open_group.
  DATA T TYPE STRING.
  T = DATASET.
  IF T EQ ' '.
    MESSAGE E110(ZX).
  ENDIF.
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      FILENAME                      = T
  FILETYPE                      = 'ASC'
      HAS_FIELD_SEPARATOR           = 'X'
  HEADER_LENGTH                 = 0
  READ_BY_LINE                  = 'X'
  DAT_MODE                      = ' '
  CODEPAGE                      = ' '
  IGNORE_CERR                   = ABAP_TRUE
  REPLACEMENT                   = '#'
  CHECK_BOM                     = ' '
IMPORTING
  FILELENGTH                    =
  HEADER                        =
    TABLES
      DATA_TAB                      = RECORD
EXCEPTIONS
  FILE_OPEN_ERROR               = 1
  FILE_READ_ERROR               = 2
  NO_BATCH                      = 3
  GUI_REFUSE_FILETRANSFER       = 4
  INVALID_TYPE                  = 5
  NO_AUTHORITY                  = 6
  UNKNOWN_ERROR                 = 7
  BAD_DATA_FORMAT               = 8
  HEADER_NOT_ALLOWED            = 9
  SEPARATOR_NOT_ALLOWED         = 10
  HEADER_TOO_LONG               = 11
  UNKNOWN_DP_ERROR              = 12
  ACCESS_DENIED                 = 13
  DP_OUT_OF_MEMORY              = 14
  DISK_FULL                     = 15
  DP_TIMEOUT                    = 16
  OTHERS                        = 17
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  LOOP AT RECORD.
    CLEAR RC.
    CLEAR ERR.
*read dataset dataset into record.
    IF SY-SUBRC <> 0. EXIT. ENDIF.
    RECORD-KTOKK_002 = '0001'.
    PERFORM BDC_DYNPRO      USING 'SAPMF02K' '0100'.
    PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                  'RF02K-KTOKK'.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                  '/00'.
    PERFORM BDC_FIELD       USING 'RF02K-LIFNR'
                                  RECORD-LIFNR_001.
    PERFORM BDC_FIELD       USING 'RF02K-KTOKK'
                                  RECORD-KTOKK_002.
    PERFORM BDC_DYNPRO      USING 'SAPMF02K' '0110'.
    PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                  'LFA1-TELX1'.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                  '/00'.
    PERFORM BDC_FIELD       USING 'LFA1-ANRED'
                                  RECORD-ANRED_003.
    PERFORM BDC_FIELD       USING 'LFA1-NAME1'
                                  RECORD-NAME1_004.
    PERFORM BDC_FIELD       USING 'LFA1-SORTL'
                                  RECORD-SORTL_005.
    PERFORM BDC_FIELD       USING 'LFA1-STRAS'
                                  RECORD-STRAS_006.
    PERFORM BDC_FIELD       USING 'LFA1-PFACH'
                                  RECORD-PFACH_007.
    PERFORM BDC_FIELD       USING 'LFA1-ORT01'
                                  RECORD-ORT01_008.
    PERFORM BDC_FIELD       USING 'LFA1-ORT02'
                                  RECORD-ORT02_009.
    PERFORM BDC_FIELD       USING 'LFA1-LAND1'
                                  RECORD-LAND1_010.
    PERFORM BDC_FIELD       USING 'LFA1-REGIO'
                                  RECORD-REGIO_011.
    PERFORM BDC_FIELD       USING 'LFA1-SPRAS'
                                  RECORD-SPRAS_012.
    PERFORM BDC_FIELD       USING 'LFA1-TELF1'
                                  RECORD-TELF1_013.
    PERFORM BDC_FIELD       USING 'LFA1-TELF2'
                                  RECORD-TELF2_014.
    PERFORM BDC_DYNPRO      USING 'SAPMF02K' '0120'.
    PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                  'LFA1-KUNNR'.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                  '=VW'.
    PERFORM BDC_DYNPRO      USING 'SAPMF02K' '0130'.
    PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                  'LFBK-BANKN(01)'.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                  '=ENTR'.
    PERFORM BDC_FIELD       USING 'LFBK-BANKS(01)'
                                  RECORD-BANKS_01_015.
    PERFORM BDC_FIELD       USING 'LFBK-BANKL(01)'
                                  RECORD-BANKL_01_016.
    PERFORM BDC_FIELD       USING 'LFBK-BANKN(01)'
                                  RECORD-BANKN_01_017.
    PERFORM BDC_DYNPRO      USING 'SAPMF02K' '0130'.
    PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                  'LFBK-BANKS(01)'.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                  '=UPDA'.
    PERFORM BDC_TRANSACTION USING 'XK01' CHANGING ERR RC.
    DATA: SERIAL TYPE I VALUE 1.
    IF RC <> 0.
      FAILCOUNT = FAILCOUNT + 1.
      CLEAR ERRORITAB.
      ERRORITAB-SERIAL = SERIAL.
      ERRORITAB-LIFNR_001 = RECORD-LIFNR_001.
      ERRORITAB-KTOKK_002 = RECORD-KTOKK_002.
      ERRORITAB-ANRED_003 = RECORD-ANRED_003.
      ERRORITAB-NAME1_004 = RECORD-NAME1_004.
      ERRORITAB-SORTL_005 = RECORD-SORTL_005.
      ERRORITAB-STRAS_006 = RECORD-STRAS_006.
      ERRORITAB-PFACH_007 = RECORD-PFACH_007.
      ERRORITAB-ORT01_008 = RECORD-ORT01_008.
      ERRORITAB-ORT02_009 = RECORD-ORT02_009.
      ERRORITAB-LAND1_010 = RECORD-LAND1_010.
      ERRORITAB-REGIO_011 = RECORD-REGIO_011.
      ERRORITAB-SPRAS_012 = RECORD-SPRAS_012.
      ERRORITAB-TELF1_013 = RECORD-TELF1_013.
      ERRORITAB-TELF2_014 = RECORD-TELF2_014.
      ERRORITAB-BANKS_01_015 = RECORD-BANKS_01_015.
      ERRORITAB-BANKL_01_016 = RECORD-BANKL_01_016.
      ERRORITAB-BANKN_01_017 = RECORD-BANKN_01_017.
      ERRORITAB-ERRORMSG = ERR.
      SERIAL = SERIAL + 1.
      APPEND ERRORITAB.
      MODIFY RECORD TRANSPORTING KTOKK_002.
      DELETE RECORD WHERE KTOKK_002 = '0001'.
    ELSE.
      SUCCESSCNT = SUCCESSCNT + 1.
    ENDIF.
  ENDLOOP.
display output********************************************************
  SKIP.
  FORMAT COLOR 5 INTENSIFIED OFF.
  WRITE:/ 'No. of records successfully uploaded: '.
  FORMAT COLOR 4 INTENSIFIED OFF.
  WRITE: SUCCESSCNT.
Displaying the success table******************************************
  IF SUCCESSCNT <> 0.
    SKIP.
    FORMAT COLOR 4 INTENSIFIED OFF.
    WRITE:/ 'Successful Records'.
    FORMAT COLOR 7 INTENSIFIED ON.
    WRITE:/(261) SY-ULINE,
          / SY-VLINE,
            'S.NO',                               007 SY-VLINE,
            'VENDOR ACC.NUM',                     023 SY-VLINE,
            'VENDOR ACC GROUP',                   041 SY-VLINE,
            'TITLE',                              048 SY-VLINE,
            'VENDOR NAME',                        064 SY-VLINE,
            'SORT FIELD',                         076 SY-VLINE,
            'HOUSE NO.& STREET',                  101 SY-VLINE,
            'PO.BOX NO',                          116 SY-VLINE,
            'CITY',                               129 SY-VLINE,
            'DISTRICT',                           141 SY-VLINE,
            'COUNTRY KEY',                        156 SY-VLINE,
            'REGION',                             166 SY-VLINE,
            'LANGUAGE KEY',                       180 SY-VLINE,
            'TELEPHONE NO 1',                     196 SY-VLINE,
            'TELEPHONE NO 2',                     213 SY-VLINE,
            'BANK COUNTRY KEY',                   231 SY-VLINE,
            'BANK KEY',                           241 SY-VLINE,
            'BANK ACC.NO',                        261 SY-VLINE,
            /1(261) SY-ULINE.
    FORMAT COLOR 4 INTENSIFIED ON.
    SERIAL = 1.
   SORT RECORD BY LIFNR_001.
    LOOP AT RECORD.
      WRITE:/ SY-VLINE,
      SERIAL LEFT-JUSTIFIED,          007 SY-VLINE,
      RECORD-LIFNR_001(016),          023 SY-VLINE,
      RECORD-KTOKK_002(004),          041 SY-VLINE,
      RECORD-ANRED_003(015),          048 SY-VLINE,
      RECORD-NAME1_004(035),          064 SY-VLINE,
      RECORD-SORTL_005(010),          076 SY-VLINE,
      RECORD-STRAS_006(035),          101 SY-VLINE,
      RECORD-PFACH_007(010),          116 SY-VLINE,
      RECORD-ORT01_008(035),          129 SY-VLINE,
      RECORD-ORT02_009(035),          141 SY-VLINE,
      RECORD-LAND1_010(003),          156 SY-VLINE,
      RECORD-REGIO_011(003),          166 SY-VLINE,
      RECORD-SPRAS_012(002),          180 SY-VLINE,
      RECORD-TELF1_013(016),          196 SY-VLINE,
      RECORD-TELF2_014(016),          213 SY-VLINE,
      RECORD-BANKS_01_015(003),       231 SY-VLINE,
      RECORD-BANKL_01_016(015),       241 SY-VLINE,
      RECORD-BANKN_01_017(018),       261 SY-VLINE.
      WRITE:/(261) SY-ULINE.
      SERIAL = SERIAL + 1.
    ENDLOOP.
    WRITE:/1(261) SY-ULINE.
  ENDIF.
  SKIP.
  FORMAT COLOR 5 INTENSIFIED OFF.
  WRITE:/ 'No. of records not uploaded: '.
  FORMAT COLOR 4 INTENSIFIED OFF.
  WRITE: FAILCOUNT.
*Displaying the error table
  IF FAILCOUNT <> 0.
    SKIP.
    FORMAT COLOR 4 INTENSIFIED OFF.
    WRITE:/(320) SY-ULINE,
            'Error Records'.
    FORMAT COLOR 7 INTENSIFIED ON.
    WRITE:/ SY-ULINE, SY-VLINE,
            'S.NO',                               007 SY-VLINE,
            'VENDOR ACC.NUM',                     023 SY-VLINE,
            'VENDOR ACC GROUP',                   041 SY-VLINE,
            'TITLE',                              048 SY-VLINE,
            'VENDOR NAME',                        064 SY-VLINE,
            'SORT FIELD',                         076 SY-VLINE,
            'HOUSE NO.& STREET',                  101 SY-VLINE,
            'PO.BOX NO',                          116 SY-VLINE,
            'CITY',                               129 SY-VLINE,
            'DISTRICT',                           141 SY-VLINE,
            'COUNTRY KEY',                        156 SY-VLINE,
            'REGION',                             166 SY-VLINE,
            'LANGUAGE KEY',                       180 SY-VLINE,
            'TELEPHONE NO 1',                     196 SY-VLINE,
            'TELEPHONE NO 2',                     213 SY-VLINE,
            'BANK COUNTRY KEY',                   231 SY-VLINE,
            'BANK KEY',                           241 SY-VLINE,
            'BANK ACC.NO',                        261 SY-VLINE,
            'ERROR MESSAGE',                      320 SY-VLINE.
    WRITE:/(320) SY-ULINE.
    FORMAT COLOR 4 INTENSIFIED ON.
   SORT ERRORITAB BY LIFNR_001.
    LOOP AT ERRORITAB.
      WRITE:/ SY-VLINE,
            ERRORITAB-SERIAL LEFT-JUSTIFIED,          007 SY-VLINE,
            ERRORITAB-LIFNR_001 ,       023 SY-VLINE,
            ERRORITAB-KTOKK_002,       041 SY-VLINE,
            ERRORITAB-ANRED_003,       048 SY-VLINE,
            ERRORITAB-NAME1_004,       064 SY-VLINE,
            ERRORITAB-SORTL_005,       076 SY-VLINE,
            ERRORITAB-STRAS_006,       101 SY-VLINE,
            ERRORITAB-PFACH_007,       116 SY-VLINE,
            ERRORITAB-ORT01_008,       129 SY-VLINE,
            ERRORITAB-ORT02_009,       141 SY-VLINE,
            ERRORITAB-LAND1_010,       156 SY-VLINE,
            ERRORITAB-REGIO_011,       166 SY-VLINE,
            ERRORITAB-SPRAS_012,       180 SY-VLINE,
            ERRORITAB-TELF1_013,       196 SY-VLINE,
            ERRORITAB-TELF2_014,       213 SY-VLINE,
            ERRORITAB-BANKS_01_015,    231 SY-VLINE,
            ERRORITAB-BANKL_01_016,    241 SY-VLINE,
            ERRORITAB-BANKN_01_017,    261 SY-VLINE,
            ERRORITAB-ERRORMSG,        320 SY-VLINE.
      WRITE:/(320) SY-ULINE.
    ENDLOOP.
    WRITE:/ SY-ULINE.
  ENDIF.
hope this ll help you..
regards,
prema.A

Similar Messages

  • How to print the row  ,column,and particular cell in separate color

    how to print the row  ,column,and particular cell in separate color IN ALV GRID

    HI,
    Here you go good program links
    <a href="http://www.sapfans.com/forums/viewtopic.php?t=52107">How to Set Color to a Cell in AVL</a>
    <a href="http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm">ALV Grid Coloring</a>
    Thanks
    Mahesh

  • Please help me how concatenate all the error messages and send it as out parameter value.

    Hi Experts,
    Please help me how concatenate all the error messages and send it as out parameter value.
    Thanks.

    Agree with Billy, exception handling is not something that is done by passing parameters around.
    PL/SQL, like other languages, provides a suitable exception handling mechanism which, if used properly, works completely fine.  Avoid misuing PL/SQL by trying to implement some other way of handling them.

  • How to rectify the error message " duplicate data records found"

    Hi,
    How to  rectify the error "duplicate data records found" , PSA is not there.
    and give me brief description about RSRV
    Thanks in advance,
    Ravi Alakunlta

    Hi Ravi,
    In the Info Package screen...Processing tab...check the option Do not allow Duplicate records.
    RSRV is used for Repair and Analysis purpose.
    If you found Duplicate records in the F fact table...Compress it then Duplicate records will be summarized in the Cube.
    Hope this helps.

  • Delivery document how to print the BOM Parent and Child items

    Hi,
    I have a production BOM. In Delivery document how to print the Parent and Child items Item Code and Qty.At the time
    of add a delivery document Inventory stock redused only in Parent Item not child item because child item stock already reduced in issue for production.

    If you need to print both the BOM Parent and Child items, you have to create your own report. BOM is only for production if it is not Sales type.
    Thanks,
    Gordon

  • How to print the current date and time?

    Hi Friends!
    I have tried this program to print the current time and date,
    #include <iostream>
    #include <time.h>
    using namespace std;
    int main()
    time_t tim;
    time(&tim);
    cout << ctime(&tim);
    return 0;
    But it show the warning as;
    warning C4996: 'ctime': This function or variable may be unsafe. Consider using ctime_s instead.
    Can anyone suggest whats wrong with this?

    i also got many warring when i use old version keyword. as i note on think thatin new vc++ has many keyword change with _s. the old keyword works even get warring.or you can change to as it suggest.For About ctime_s
    Check this link for more detail (RefLink)
    No, it shows error, when you use ctime_s instead of ctime.
    error C2660: 'ctime_s' : function does not take 1 arguments

  • How to rectify the errors through call transaction metod in bdc

    how to rectify the errors through call transaction metod in bdc

    Hi ,
    View the highlited part of the below code.
    REPORT ygfrivat1 NO STANDARD PAGE HEADING
                     LINE-SIZE 165
                     MESSAGE-ID yif_groc.
    Program     YGFRIVAT1
    Function    Report to Upload the VAT Adjustment File.
    Author      ARENAPU
    Date        11.05.2007
    PMTS        AM12810157
    Transport   G6DK937834
    Description:
    Modification log:
    1. Changed by  :
       Changed on  :
       PMTS        :
       Transport   :
       Tag         :
       Description :
           T A B L E S   D E C L A R A T I O N S
    TABLES: edidc,  "Control record (IDoc)
            edids,  "Status Record (IDoc)
            t001w.
    Internal Tables Declaration.
    Internal table to hold data from table EDIDS
    DATA: BEGIN OF t_edids OCCURS 0,
           docnum LIKE edids-docnum,
           logdat LIKE edids-logdat,
           logtim LIKE edids-logtim,
           countr LIKE edids-countr,
           credat LIKE edids-credat,
           uname  LIKE edids-uname,
          END OF t_edids,
    Internal table to hold data from table EDIDC
          BEGIN OF t_edidc OCCURS 0,
           docnum LIKE edidc-docnum,
           rcvprt LIKE edidc-rcvprt,
           rcvprn LIKE edidc-rcvprn,
           credat LIKE edidc-credat,
          END OF t_edidc,
    Internal table to hold data from upload file
          BEGIN OF t_tab OCCURS 0,
           cust(10),        "site/customer number
           date(10),        "transaction date
           currency(04),    "currency
           extnbr(15),      "external reference number
           pos-cont(05),    "POS controler
           pos-id(25),      "POS id
           cashier(10),     "cashier name
           qualif(04),      "qualifier of the article
           matnr(25),       "article number
           qty(10),         "quantity
           sale(16),        "sale value
           pos-tr(04),      "POS transfert type
           paymeth(04),     "payment method
           final(35),       "final price
           tarcur(04),      "target currency
           assign(35),      "assignment day
           error,
          END OF t_tab,
    Internal table for Report display.
          BEGIN OF t_tab1 OCCURS 0,
           cust(10),                    "site/customer number
           date(10),                    "transaction date
           currency(04),                "currency
           extnbr(15),                  "external reference number
           pos-cont(05),                "POS controler
           pos-id(25),                  "POS id
           cashier(10),                 "cashier name
           qualif(04),                  "qualifier of the article
           matnr(25),                   "article number
           qty(16)   TYPE p DECIMALS 2, "quantity
           sale(16)  TYPE p DECIMALS 2, "sale value
           pos-tr(04),                  "POS transfert type
           paymeth(04),                 "payment method
           final(16) TYPE p DECIMALS 2, "final price
           tarcur(04),                  "target currency
           assign(35),                  "assignment day
          END OF t_tab1,
          t_tab_temp LIKE t_tab OCCURS 0 WITH HEADER LINE,
    Internal table to Validate Customer no.
          BEGIN OF t_check OCCURS 0,
           werks LIKE t001w-werks,
           vkorg LIKE t001w-vkorg,
           value(40),
          END OF t_check,
          t_check_temp LIKE t_check OCCURS 0 WITH HEADER LINE.
    Internal table to hold data from table ZCS_PARAM.
    DATA: BEGIN OF t_zcs_param OCCURS 0.
            INCLUDE STRUCTURE zcs_param.
    DATA: vkorg LIKE t001w-vkorg,
          END OF t_zcs_param.
    *Internal table to hold Messages.
    DATA: BEGIN OF t_message OCCURS 0,
             msgnum TYPE msgnum,
             msgtyp TYPE msgtyp,
             msgtxt TYPE msgtext,
           END OF t_message.
    *Work area for table t_message
    DATA : w_message LIKE LINE OF t_message.
    Internal table to hold BDC data
    DATA: t_bdcdata LIKE bdcdata    OCCURS 0 WITH HEADER LINE,
    Internal table to collect error messages
          messtab   LIKE bdcmsgcoll OCCURS 0  WITH HEADER LINE.
    *Internal table to hold messages from call transaction
    DATA: BEGIN OF t_text OCCURS 0,
           desc(150),
           msgtxt(100),
          END OF t_text.
           D A T A   D E C L A R A T I O N S
    DATA: n TYPE i,
          gv_status(11) TYPE c, "Shows status, Production or Test
          gv_exit TYPE c,  "Exit Flag
          gv_qty(16)   TYPE p DECIMALS 2, "Variable to sum Quantity
          gv_sale(16)  TYPE p DECIMALS 2, "Variable to sum Amount
          gv_final(16) TYPE p DECIMALS 2. "Variable to sum Final Amount
    DATA: w_text(100),
          gv_mode TYPE c,
          error TYPE c.  "Flag to Indicate error.
    CONSTANSTS DECLARATION
    CONSTANTS : gc_fieldname LIKE dynpread-fieldname VALUE 'P_FNAME',
                gc_seq_no LIKE zcs_param-seq_no VALUE '00110',
                gc_object LIKE zcs_param-object VALUE 'YGFVAT',
                gc_paraname LIKE zcs_param-paraname VALUE 'VKORG',
                gc_back TYPE c VALUE 'N',
                gc_error TYPE c VALUE 'E',
                gc_all TYPE c VALUE 'A'.
               S E L E C T I O N   S C R E E N
    SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.
    PARAMETERS : p_fname LIKE rlgrap-filename OBLIGATORY.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(31) text-002 FOR FIELD p_test.
    PARAMETERS : p_test AS CHECKBOX.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK a1.
    SELECTION-SCREEN BEGIN OF BLOCK a2 WITH FRAME TITLE text-006.
    PARAMETERS : rb_back RADIOBUTTON GROUP rb1 DEFAULT 'X',
                 rb_error RADIOBUTTON GROUP rb1,
                 rb_all RADIOBUTTON GROUP rb1.
    SELECTION-SCREEN END OF BLOCK a2.
    AT SELECTION SCREEN
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.
    *Subroutine to provide F4 help for file name
      PERFORM fr_get_filename.
           I N I T I A L I Z A T I  O N
    INITIALIZATION.
    *Subroutine to check authorization.
    PERFORM fr_authority_check.
            T O P - O F - P A G E
    TOP-OF-PAGE.
    *Subroutine to diplay header
      PERFORM fr_display_header.
             S T A R T - O F - S E L E C T I O N
    START-OF-SELECTION.
    *Subroutine to upload data from presentation server.
      PERFORM fr_upload_data.
    *Subroutine to validate records from uploaded file.
      PERFORM fr_validate_data.
    *Subroutine to build report internal table.
      PERFORM fr_build_rep.
             E N D - O F - S E L E C T I O N
    END-OF-SELECTION.
    *Subroutine to display report.
      PERFORM fr_write_report.
            F O R M   S U B R O U T I N E S
    *&      Form  fr_get_filename
          text
    FORM fr_get_filename.
      DATA : lv_repid LIKE sy-repid,         " Report id
             lv_file  LIKE ibipparms-path.   " File Path
      lv_repid = sy-repid.
    F4 help for file path.
      CALL FUNCTION 'F4_FILENAME'
           EXPORTING
                program_name  = lv_repid
                dynpro_number = syst-dynnr
                field_name    = gc_fieldname                    " p_fname1
           IMPORTING
                file_name     = lv_file.
      IF NOT lv_file EQ space.
        p_fname = lv_file.
      ELSE.
        MESSAGE e999 WITH 'Invalid Path'(005).
      ENDIF.
    ENDFORM.                    " fr_get_filename
    *&      Form  fr_upload_data
          text
    FORM fr_upload_data.
      DATA: lv_fname TYPE string.
      CLEAR lv_fname.
      lv_fname = p_fname.
    Uploading file from PC or presentation server to internal table.
      CALL FUNCTION 'GUI_UPLOAD'
           EXPORTING
                filename            = lv_fname
                filetype            = 'ASC'
                has_field_separator = 'X'
           TABLES
                data_tab            = t_tab
           EXCEPTIONS
                file_open_error     = 1.
      IF sy-subrc <> 0.
        DESCRIBE TABLE t_message LINES n.
        w_message-msgnum = n + 1.
        w_message-msgtyp = 'E'.
        MOVE text-m01  TO w_message-msgtxt.
        APPEND w_message TO t_message.
    Subroutine for writing log.
        PERFORM fr_write_log.
      ENDIF.
    ENDFORM.                    " fr_upload_data
    *&      Form  fr_validate_data
          text
    FORM fr_validate_data.
      DATA : lv_lines1 TYPE i,
             lv_lines2 TYPE i.
    *Obtain Status depending on Check box selected.
      IF p_test IS INITIAL.
        gv_status = 'PRODUCTION'.
      ELSE.
        gv_status = 'TEST RUN'.
      ENDIF.
    *Batch Mode
      CLEAR gv_mode.
      IF rb_back EQ 'X'.          "No Display
        MOVE gc_back TO gv_mode.
      ELSEIF rb_error EQ 'X'.     "Error Only
        MOVE gc_error TO gv_mode.
      ELSEIF rb_all EQ 'X'.       "All Screens
        MOVE gc_all TO gv_mode.
      ENDIF.
      IF NOT t_tab[] IS INITIAL.
        SORT t_tab BY cust.
        REFRESH t_tab_temp.
        t_tab_temp[] = t_tab[].
        SORT t_tab_temp BY cust.
        DELETE ADJACENT DUPLICATES FROM t_tab_temp COMPARING cust.
        IF NOT t_tab_temp[] IS INITIAL.
          SELECT werks vkorg FROM t001w
                             INTO TABLE t_check
                             FOR ALL ENTRIES IN t_tab_temp
                             WHERE werks = t_tab_temp-cust+0(4).
          IF sy-subrc = 0.
            SORT t_check BY werks.
          ENDIF.
          LOOP AT t_check.
            IF t_check-vkorg <> ' '.
              MOVE t_check-vkorg TO t_check-value.
              MODIFY t_check TRANSPORTING value.
            ENDIF.
          ENDLOOP.
        ENDIF.
        FREE t_tab_temp.
      ENDIF.
      IF NOT t_check[] IS INITIAL.
        REFRESH t_check_temp.
        t_check_temp[] = t_check[].
        SORT t_check_temp BY value.
        DELETE ADJACENT DUPLICATES FROM t_check_temp COMPARING value.
        IF NOT t_check_temp[] IS INITIAL.
          SELECT * FROM zcs_param INTO TABLE t_zcs_param
                   FOR ALL ENTRIES IN t_check_temp
                   WHERE seq_no   EQ gc_seq_no
                     AND object   EQ gc_object
                     AND paraname EQ gc_paraname
                     AND value    EQ t_check_temp-value.
          IF sy-subrc = 0.
            SORT t_zcs_param BY value.
          ENDIF.
        ENDIF.
        FREE t_check_temp.
      ENDIF.
      IF NOT t_tab[] IS INITIAL.
        LOOP AT t_tab.
          READ TABLE t_check WITH KEY werks = t_tab-cust BINARY SEARCH.
          IF sy-subrc <> 0.
            MOVE 'X' TO t_tab-error.
            MODIFY t_tab TRANSPORTING error.
            DESCRIBE TABLE t_message LINES n.
            w_message-msgnum = n + 1.
            w_message-msgtyp = 'E'.
            CONCATENATE t_tab-cust text-030
            INTO w_message-msgtxt SEPARATED BY space.
            APPEND w_message TO t_message.
    Subroutine for writing log.
            PERFORM fr_write_log.
            EXIT.
          ELSE.
            READ TABLE t_zcs_param WITH KEY value = t_check-vkorg
                                                         BINARY SEARCH.
            IF sy-subrc <> 0.
              MOVE 'X' TO t_tab-error.
              MODIFY t_tab TRANSPORTING error.
              DESCRIBE TABLE t_message LINES n.
              w_message-msgnum = n + 1.
              w_message-msgtyp = 'E'.
              CONCATENATE text-003 t_tab-cust text-004 t_check-vkorg
              INTO w_message-msgtxt SEPARATED BY space.
              APPEND w_message TO t_message.
    Subroutine for writing log.
              PERFORM fr_write_log.
              EXIT.
            ELSE.
              PERFORM fr_format_tab.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDIF.
      DESCRIBE TABLE t_tab LINES lv_lines1.
      IF lv_lines1 <> 0.
        DELETE t_tab WHERE error EQ 'X'.
      ENDIF.
      DESCRIBE TABLE t_tab LINES lv_lines2.
      IF lv_lines2 <> 0.
        IF lv_lines2 <> lv_lines1.
          EXIT.
        ELSE.
          IF p_test IS INITIAL.
            LOOP AT t_tab.
    *Subroutine to build BDC table
              PERFORM fr_fill_bdctab.
    *Subroutine to Post Data into SAP.
              PERFORM fr_data_posting.
            ENDLOOP.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDFORM.                    " fr_validate_data
    *&      Form  fr_write_log
          text
    FORM fr_write_log.
      CLEAR error.
      error = 'X'.
      WRITE:/1 'Msg No'(027), 10 'Type'(028), 20 'Text'(029).
      ULINE:/1(120).
      FORMAT RESET.
      LOOP AT t_message.
        IF t_message-msgtyp = 'E'.
          FORMAT COLOR 6 INTENSIFIED .
        ELSEIF t_message-msgtyp = 'W'.
          FORMAT COLOR 3 INTENSIFIED .
        ELSEIF t_message-msgtyp = 'I'.
          FORMAT COLOR 5 INTENSIFIED .
        ENDIF.
        WRITE:/1 t_message-msgnum,
              10 t_message-msgtyp,
              20 t_message-msgtxt.
        FORMAT RESET.
      ENDLOOP.
      ULINE:/1(120).
    ENDFORM.                    " fr_write_log
    *&      Form  fr_write_report
          text
    FORM fr_write_report.
      CLEAR gv_exit.
      LOOP AT t_message.
        IF t_message-msgtyp = 'E'.
          gv_exit = 'X'.
          EXIT.
        ENDIF.
      ENDLOOP.
      IF NOT gv_exit IS INITIAL.
        EXIT.
      ELSE.
        PERFORM fr_display_report.
        IF NOT t_text[] IS INITIAL.
    Subroutine for Display Call Transaction messages.
          PERFORM fr_write_msg.
        ENDIF.
      ENDIF.
    ENDFORM.                    " fr_write_report
    *&      Form  fr_display_report
          text
    FORM fr_display_report.
      IF NOT t_tab1[] IS INITIAL.
        CLEAR: gv_qty, gv_sale, gv_final.
        LOOP AT t_tab1.
          WRITE:/1(10) t_tab1-cust,
                13(10) t_tab1-date,
                25(05) t_tab1-currency,
                32(14) t_tab1-extnbr,
                48(09) t_tab1-pos-cont,
                60(18) t_tab1-matnr,
                80(16) t_tab1-qty RIGHT-JUSTIFIED ,
                98(16) t_tab1-sale RIGHT-JUSTIFIED ,
               116(07) t_tab1-paymeth,
               125(16) t_tab1-final RIGHT-JUSTIFIED,
               143(06) t_tab1-tarcur,
               152(12) t_tab1-assign.
          gv_qty   = t_tab1-qty   + gv_qty.
          gv_sale  = t_tab1-sale  + gv_sale.
          gv_final = t_tab1-final + gv_final.
        ENDLOOP.
        FORMAT COLOR 3.
        ULINE: /(164).
        WRITE:/ 'TOTALS',
          80(16) gv_qty RIGHT-JUSTIFIED,
          98(16) gv_sale RIGHT-JUSTIFIED,
         125(16) gv_final RIGHT-JUSTIFIED,
         182 ''.
        ULINE: /(164).
        FORMAT RESET.
      ENDIF.
    ENDFORM.                    " fr_display_report
    *&      Form  FR_DISPLAY_HEADER
          text
    FORM fr_display_header.
      IF error IS INITIAL.
        FORMAT COLOR 1.
        WRITE:/ 'Date upload           :'(007),   25 sy-datum,  38 ''.
        WRITE:/ 'Production or Test Run:'(008),   25 gv_status, 38 ''.
        WRITE:/ 'Upload User Logon     :'(009),   25 sy-uname,  38 ''.
        ULINE: /(164).
        WRITE:/1(04) 'Site'(010),
              13(10) 'Date'(011),
              25(05) 'Curr.'(012),
              32(14) 'Receipt'(013),
              48(09) 'Cashier'(014),
              60(18) 'Article'(015),
              92     'Qty'(016),
              102    'Item Amount'(017),
              116(7) 'M.o.P.'(018),
              128    'Tender Amount'(019),
              143(6) 'T.Curr'(020),
             152(12) 'Assignment'(021).
        ULINE:/(164).
        FORMAT RESET.
      ENDIF.
    ENDFORM.                    " FR_DISPLAY_HEADER
    *&      Form  fr_newdynpro
          text
    FORM fr_newdynpro USING program LIKE bdcdata-program
                            dynpro  LIKE bdcdata-dynpro.
      t_bdcdata-program = program .
      t_bdcdata-dynpro  = dynpro.
      t_bdcdata-dynbegin = 'X'.
      APPEND t_bdcdata.
      CLEAR t_bdcdata.
    ENDFORM.                    " fr_newdynpro
    *&      Form  fr_loadfield
          text
    FORM fr_loadfield USING field LIKE bdcdata-fnam
                            value.
      t_bdcdata-fnam = field.
      t_bdcdata-fval = value.
      APPEND t_bdcdata.
      CLEAR t_bdcdata.
    ENDFORM.                    " fr_loadfield
    *&      Form  fr_fill_bdctab
          text
    FORM fr_fill_bdctab.
      REFRESH t_bdcdata.
      PERFORM fr_newdynpro USING 'SAPMWPUK' '100'.
      PERFORM fr_loadfield USING 'G_FILIALE' t_tab-cust.
      PERFORM fr_loadfield USING 'G_DATUM'   t_tab-date.
      PERFORM fr_loadfield USING 'BDC_OKCODE' 'BON'.
      PERFORM fr_newdynpro USING 'SAPMWPUK' '500'.
      PERFORM fr_loadfield USING 'WPSCB01-POSKREIS'   t_tab-pos-cont.
      PERFORM fr_loadfield USING 'WPSCB01-KASSID'     t_tab-pos-id.
      PERFORM fr_loadfield USING 'WPSCB01-BELEGWAERS' t_tab-currency.
      PERFORM fr_loadfield USING 'WPSCB01-CSHNAME'    t_tab-cashier.
      PERFORM fr_loadfield USING 'WPSCB01-BONNUMMER'  t_tab-extnbr.
      PERFORM fr_loadfield USING 'E1WPB02-QUALARTNR(01)'  t_tab-qualif.
      PERFORM fr_loadfield USING 'E1WPB02-ARTNR(01)'      t_tab-matnr.
      PERFORM fr_loadfield USING 'E1WPB02-MENGE(01)'      t_tab-qty.
      PERFORM fr_loadfield USING 'WPSCB03-KONDVALUE(01)'  t_tab-sale.
      PERFORM fr_loadfield USING 'E1WPB02-VORGANGART(01)' t_tab-pos-tr.
      PERFORM fr_loadfield USING 'BDC_OKCODE' 'ZAHL'.
      PERFORM fr_newdynpro USING 'SAPMWPUK' '530'.
      PERFORM fr_loadfield USING 'WPSCB06-ZAHLART'  t_tab-paymeth.
      PERFORM fr_loadfield USING 'WPSCB06-SUMME'    t_tab-final.
      PERFORM fr_loadfield USING 'WPSCB06-WAEHRUNG' t_tab-tarcur.
      PERFORM fr_loadfield USING 'WPSCB06-ZUONR'    t_tab-assign.
      PERFORM fr_loadfield USING 'BDC_OKCODE' 'SAVE'.
      PERFORM fr_newdynpro USING 'SAPMWPUK' '530'.
      PERFORM fr_loadfield USING 'WPSCB06-ZAHLART'  t_tab-paymeth.
      PERFORM fr_loadfield USING 'WPSCB06-SUMME'    t_tab-final.
      PERFORM fr_loadfield USING 'WPSCB06-WAEHRUNG' t_tab-tarcur.
      PERFORM fr_loadfield USING 'WPSCB06-ZUONR'    t_tab-assign.
      PERFORM fr_loadfield USING 'BDC_OKCODE' 'BACK'.
      PERFORM fr_newdynpro USING 'SAPLSPO1' '0200'.
      PERFORM fr_loadfield USING 'BDC_OKCODE' 'YES'.
      PERFORM fr_newdynpro USING 'SAPMWPUK' '100'.
      PERFORM fr_loadfield USING 'G_FILIALE' t_tab-cust.
      PERFORM fr_loadfield USING 'G_DATUM'   t_tab-date.
      PERFORM fr_loadfield USING 'BDC_OKCODE' 'BACK'.
    ENDFORM.                    " fr_fill_bdctab
    *&      Form  fr_data_posting
          text
    FORM fr_data_posting.
      IF NOT t_bdcdata[] IS INITIAL.
        REFRESH messtab.
        CALL TRANSACTION 'WPUK' USING t_bdcdata
                                MODE gv_mode
                                UPDATE 'S'
                                MESSAGES INTO messtab.
        IF sy-subrc = 0 .
          CLEAR w_text.
          LOOP AT messtab.
            CALL FUNCTION 'FORMAT_MESSAGE'
                 EXPORTING
                      id        = messtab-msgid
                      lang      = sy-langu
                      no        = messtab-msgnr
                      v1        = messtab-msgv1
                      v2        = messtab-msgv2
                      v3        = messtab-msgv3
                      v4        = messtab-msgv4
                 IMPORTING
                      msg       = w_text
                 EXCEPTIONS
                      not_found = 1
                      OTHERS    = 2.
            MOVE w_text TO t_text-msgtxt.
            CONCATENATE 'Site:'(031)    t_tab-cust
                        'Article:'(024) t_tab-matnr
                        'Posted Sucessfully'(032)
              INTO t_text-desc SEPARATED BY space.
            APPEND t_text.
            CLEAR t_text.
          ENDLOOP.
        ELSE.
          CLEAR w_text.
          LOOP AT messtab.
            CALL FUNCTION 'FORMAT_MESSAGE'
                 EXPORTING
                      id        = messtab-msgid
                      lang      = sy-langu
                      no        = messtab-msgnr
                      v1        = messtab-msgv1
                      v2        = messtab-msgv2
                      v3        = messtab-msgv3
                      v4        = messtab-msgv4
                 IMPORTING
                      msg       = w_text
                 EXCEPTIONS
                      not_found = 1
                      OTHERS    = 2.
            MOVE w_text TO t_text-msgtxt.
            IF messtab-msgnr EQ '213'.
              CONCATENATE 'Site:'(031)    t_tab-cust
                          'Article:'(024) t_tab-matnr
                          'Posted Sucessfully'(032)
               INTO t_text-desc SEPARATED BY space.
              APPEND t_text.
              CLEAR t_text.
              EXIT.        ELSE.
              CONCATENATE 'Site:'(031)    t_tab-cust
                          'Article:'(024) t_tab-matnr
                          'Not Posted'(033)
               INTO t_text-desc SEPARATED BY space.
              APPEND t_text.
              CLEAR t_text.
            ENDIF.
          ENDLOOP.
        ENDIF.
      ENDIF.
    ENDFORM.                    " fr_data_posting
    *&      Form  fr_authority_check
          text
    FORM fr_authority_check.
      AUTHORITY-CHECK OBJECT 'Y_VATADJ'
               ID 'VKORG' FIELD t001w-vkorg
               ID 'TCD'   FIELD 'YGFVAT'.
      IF sy-subrc NE 0.
        MESSAGE e999 WITH text-m02.
      ENDIF.
    ENDFORM.                    " fr_authority_check
    *&      Form  fr_write_msg
          text
    FORM fr_write_msg.
      SKIP.
      ULINE:/(164).
      WRITE:/
      'Messages encountered while Calling Transaction WPUK'(025),
          90 'Message Text'(026).
      ULINE:/1(164).
      LOOP AT t_text.
        WRITE:/1 t_text-desc,
              90 t_text-msgtxt,
              164 ''.
      ENDLOOP.
      ULINE:/1(164).
    ENDFORM.                    " fr_write_msg
    *&      Form  FR_BUILD_REP
          text
    FORM fr_build_rep.
      IF error IS INITIAL.
        IF NOT t_tab[] IS INITIAL.
          LOOP AT t_tab.
            MOVE:
              t_tab-cust     TO t_tab1-cust,        "site/customer number
              t_tab-date     TO t_tab1-date,        "transaction date
              t_tab-currency TO t_tab1-currency,    "currency
            t_tab-extnbr   TO t_tab1-extnbr,      "external reference number
              t_tab-pos-cont TO t_tab1-pos-cont,    "POS controler
              t_tab-pos-id   TO t_tab1-pos-id,      "POS id
              t_tab-cashier  TO t_tab1-cashier,     "cashier name
             t_tab-qualif   TO t_tab1-qualif,      "qualifier of the article
              t_tab-matnr    TO t_tab1-matnr,       "article number
              t_tab-pos-tr   TO t_tab1-pos-tr,      "POS transfert type
              t_tab-paymeth  TO t_tab1-paymeth,     "payment method
              t_tab-tarcur   TO t_tab1-tarcur,      "target currency
              t_tab-assign   TO t_tab1-assign.
            REPLACE ',' WITH '.' INTO t_tab-qty.
            CONDENSE t_tab-qty NO-GAPS.
            MOVE t_tab-qty TO t_tab1-qty.
            REPLACE ',' WITH '.' INTO t_tab-sale.
            CONDENSE t_tab-sale NO-GAPS.
            MOVE t_tab-sale TO t_tab1-sale.
            REPLACE ',' WITH '.' INTO t_tab-final.
            CONDENSE t_tab-final NO-GAPS.
            MOVE t_tab-final TO t_tab1-final.
            APPEND t_tab1.
            CLEAR t_tab1.
          ENDLOOP.
        ENDIF.
      ENDIF.
    ENDFORM.                    " FR_BUILD_REP
    *&      Form  fr_format_tab
          text
    FORM fr_format_tab.
      DATA : lv_qty TYPE string.
      IF NOT t_tab-qty IS INITIAL.
        IF t_tab-qty+0(1) EQ '-'.
          CLEAR lv_qty.
          MOVE t_tab-qty TO lv_qty.
          CLEAR t_tab-qty.
          SHIFT lv_qty LEFT CIRCULAR.
          CONDENSE lv_qty NO-GAPS.
          MOVE lv_qty TO t_tab-qty.
          MODIFY t_tab TRANSPORTING qty.
        ENDIF.
      ENDIF.
    ENDFORM.                    " fr_format_tab

  • How to print the attribute name and value?

    Hi, All,
    I am learning Jaxp and DOM.
    I am trying to parse a xml document using DOM as
    DocumentBuilder builder = factory.newDocumentBuilder();
    document = builder.parse( new File(argv[0]) );
    Assume that my xml have three levels. For each node, there is only one attribute (key).
    Now I would like to print the name of all the nodes and the name of all the attributes and their values.
    Would youn please provide me some ideas?
    Thanks.
    AG

    http://java.sun.com/webservices/docs/1.3/tutorial/doc/JAXPDOM4.html

  • How to solve the error 2009 and 3004

    any idea what is error code 2009 n 3004 ?

    Error 2009
    If you experience this issue on a Mac, disconnect third-party devices, hubs, spare cables, displays, reset the SMC, and then try to restore.
    If you are using a Windows computer, remove all USB devices and spare cables other than your keyboard, mouse, and the device, restart the computer, and try to restore.
    If that does not resolve the issue, see Error 1604 above. If the issue persists, it may be related to conflicting security software on your computer.
    Error 3004
    No internet connection during the firmware restore.
    iTunes can't connect to gs.apple.com. Maybe Port 80 and Port 443 is blocked. Open it on your router.

  • How do we print the error logs

    hi friends , i want to print the error log file of a bdc session method ,can any one sugest me a answer

    Check out this Sample Program
    *& Report                                             *
    *& This program is to transfer data from flat file to transaction 'FD01'
    REPORT  zgopi_report
    NO STANDARD PAGE HEADING
                            LINE-SIZE 255
                            MESSAGE-ID ZRASH.
    *                 Internal Table Declarations                          *
    *--Internal Table for Data Uploading.
    DATA : BEGIN OF IT_FFCUST OCCURS 0,
             KUNNR(10),
             BUKRS(4),
             KTOKD(4),
             ANRED(15),
             NAME1(35),
             SORTL(10),
             STRAS(35),
             ORT01(35),
             PSTLZ(10),
             LAND1(3),
             SPRAS(2),
             AKONT(10),
           END OF IT_FFCUST.
    *--Internal Table to Store Error Records.
    DATA : BEGIN OF IT_ERRCUST OCCURS 0,
             KUNNR(10),
             EMSG(255),
           END OF IT_ERRCUST.
    *--Internal Table to Store Successful Records.
    DATA : BEGIN OF IT_SUCCUST OCCURS 0,
             KUNNR(10),
             SMSG(255),
           END OF IT_SUCCUST.
    *--Internal Table for Storing the BDC data.
    DATA : IT_CUSTBDC LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
    *--Internal Table for storing the messages.
    DATA : IT_CUSTMSG LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
    DATA : V_FLAG1(1) VALUE ' ',
    "Flag used for opening session.
           V_TLINES LIKE SY-TABIX,
           "For storing total records processed.
           V_ELINES LIKE SY-TABIX,
           "For storing the no of error records.
           V_SLINES LIKE SY-TABIX.
           "For storing the no of success records.
    *          Selection screen                                            *
    SELECTION-SCREEN BEGIN OF BLOCK B1.
    PARAMETERS : V_FNAME LIKE RLGRAP-FILENAME,
                 V_SESNAM  LIKE RLGRAP-FILENAME.
    SELECTION-SCREEN END OF BLOCK B1.
    *          Start-of-selection                                          *
    START-OF-SELECTION.
    *-- Form to upload flatfile data into the internal table.
      PERFORM FORM_UPLOADFF.
    *        TOP-OF-PAGE                                                   *
    TOP-OF-PAGE.
      WRITE:/ 'Details of the error and success records for the transaction'
      ULINE.
      SKIP.
    *          End of Selection                                            *
    END-OF-SELECTION.
    *-- Form to Generate a BDC from the Uploaded Internal table
      PERFORM FORM_BDCGENERATE.
    *--To write the totals and the session name.
      PERFORM FORM_WRITEOP.
    *&      Form  form_uploadff
    *     Form to upload flatfile data into the internal table.
    FORM FORM_UPLOADFF .
    *--Variable to change the type of the parameter file name.
      DATA : LV_FILE TYPE STRING.
      LV_FILE = V_FNAME.
    *--Function to upload the flat file to the internal table.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME                      =  LV_FILE
    *     FILETYPE                      = 'ASC'
          HAS_FIELD_SEPARATOR           = 'X'
    *     HEADER_LENGTH                 = 0
    *     READ_BY_LINE                  = 'X'
    *     DAT_MODE                      = ' '
    *   IMPORTING
    *     FILELENGTH                    =
    *     HEADER                        =
        TABLES
          DATA_TAB                      = IT_FFCUST
        EXCEPTIONS
          FILE_OPEN_ERROR               = 1
          FILE_READ_ERROR               = 2
          NO_BATCH                      = 3
          GUI_REFUSE_FILETRANSFER       = 4
          INVALID_TYPE                  = 5
          NO_AUTHORITY                  = 6
          UNKNOWN_ERROR                 = 7
          BAD_DATA_FORMAT               = 8
          HEADER_NOT_ALLOWED            = 9
          SEPARATOR_NOT_ALLOWED         = 10
          HEADER_TOO_LONG               = 11
          UNKNOWN_DP_ERROR              = 12
          ACCESS_DENIED                 = 13
          DP_OUT_OF_MEMORY              = 14
          DISK_FULL                     = 15
          DP_TIMEOUT                    = 16
          OTHERS                        = 17
      IF SY-SUBRC = 0.
    *--Deleting the headings from the internal table.
        DELETE IT_FFCUST INDEX 1.
    *--Getting the total number of records uploaded.
        DESCRIBE TABLE IT_FFCUST LINES V_TLINES.
      ENDIF.
    ENDFORM.                    " form_uploadff
    *&      Form  Form_bdcgenerate
    *     Form to Generate a BDC from the Uploaded Internal table
    FORM FORM_BDCGENERATE .
    *--Generating the BDC table for the fields of the internal table.
      LOOP AT IT_FFCUST.
        PERFORM POPULATEBDC USING :
                                    'X' 'SAPMF02D' '0105',
                                    ' ' 'BDC_OKCODE'  '/00' ,
                                    ' ' 'RF02D-KUNNR' IT_FFCUST-KUNNR,
                                    ' ' 'RF02D-BUKRS' IT_FFCUST-BUKRS,
                                    ' ' 'RF02D-KTOKD' IT_FFCUST-KTOKD,
                                    'X' 'SAPMF02D' '0110' ,
                                    ' ' 'BDC_OKCODE'  '/00',
                                    ' ' 'KNA1-ANRED'  IT_FFCUST-ANRED,
                                    ' ' 'KNA1-NAME1' IT_FFCUST-NAME1,
                                    ' ' 'KNA1-SORTL'  IT_FFCUST-SORTL,
                                    ' ' 'KNA1-STRAS' IT_FFCUST-STRAS,
                                    ' ' 'KNA1-ORT01' IT_FFCUST-ORT01,
                                    ' ' 'KNA1-PSTLZ' IT_FFCUST-PSTLZ,
                                    ' ' 'KNA1-LAND1' IT_FFCUST-LAND1,
                                    ' ' 'KNA1-SPRAS' IT_FFCUST-SPRAS,
                                    'X' 'SAPMFO2D' '0120',     
                                    ' ' 'BDC_OKCODE'  '/00',
                                    'X' 'SAPMF02D' '0125',     
                                    ' ' 'BDC_OKCODE'  '/00',
                                    'X' 'SAPMF02D' '0130',     
                                    ' ' 'BDC_OKCODE'  '=ENTR',
                                    'X' 'SAPMF02D' '0340',     
                                    ' ' 'BDC_OKCODE'  '=ENTR',
                                    'X' 'SAPMF02D' '0360',
                                    ' ' 'BDC_OKCODE'  '=ENTR',
                                    'X' 'SAPMF02D' '0210',     
                                    ' ' 'KNB1-AKONT'  IT_FFCUST-AKONT,
                                    ' ' 'BDC_OKCODE'  '/00',
                                    'X' 'SAPMF02D' '0215',
                                    ' ' 'BDC_OKCODE'  '/00',
                                    'X' 'SAPMF02D' '0220',     
                                    ' ' 'BDC_OKCODE'  '/00',
                                    'X' 'SAPMF02D' '0230',     
                                    ' ' 'BDC_OKCODE'  '=UPDA'.
    *--Calling the transaction 'fd01'.
        CALL TRANSACTION 'FD01' USING IT_CUSTBDC MODE 'N' UPDATE 'S'
        MESSAGES INTO IT_CUSTMSG.
        IF SY-SUBRC <> 0.
    *--Populating the error records internal table.
          IT_ERRCUST-KUNNR = IT_FFCUST-KUNNR.
          APPEND IT_ERRCUST.
          CLEAR IT_ERRCUST.
    *--Opening a session if there is an error record.
          IF V_FLAG1 = ' '.
            PERFORM FORM_OPENSESSION.
            V_FLAG1 = 'X'.
          ENDIF.
    *--Inserting the error records into already open session.
          IF V_FLAG1 = 'X'.
            PERFORM FORM_INSERT.
          ENDIF.
    *--Populating the Success records internal table.
        ELSE.
          IT_SUCCUST-KUNNR = IT_FFCUST-KUNNR.
          APPEND IT_SUCCUST.
          CLEAR IT_SUCCUST.
        ENDIF.
    *--Displaying the messages.
        IF NOT IT_CUSTMSG[] IS INITIAL.
          PERFORM FORM_FORMATMSG.
        ENDIF.
    *--Clearing the message and bdc tables.
        CLEAR : IT_CUSTBDC[],IT_CUSTMSG[].
      ENDLOOP.
    *--Getting the total no of error records.
      DESCRIBE TABLE IT_ERRCUST LINES V_ELINES.
    *--Getting the total no of successful records.
      DESCRIBE TABLE IT_SUCCUST LINES V_SLINES.
    *--Closing the session only if it is open.
      IF V_FLAG1 = 'X'.
        PERFORM FORM_CLOSESESS.
      ENDIF.
    ENDFORM.                    " Form_bdcgenerate
    *&      Form  populatebdc
    *       FOrm to Populate the BDC table.
    FORM POPULATEBDC  USING    VALUE(P_0178)
                               VALUE(P_0179)
                               VALUE(P_0180).
      IF P_0178 = 'X'.
        IT_CUSTBDC-PROGRAM = P_0179.
        IT_CUSTBDC-DYNPRO = P_0180.
        IT_CUSTBDC-DYNBEGIN = 'X'.
      ELSE.
        IT_CUSTBDC-FNAM = P_0179.
        IT_CUSTBDC-FVAL = P_0180.
      ENDIF.
      APPEND IT_CUSTBDC.
      CLEAR IT_CUSTBDC.
    ENDFORM.                    " populatebdc
    *&      Form  FORM_OPENSESSION
    *       Form to Open a session.
    FORM FORM_OPENSESSION .
    *--Variable to convert the given session name into reqd type.
      DATA : LV_SESNAM(12).
      LV_SESNAM = V_SESNAM.
    *--Opening a session.
      CALL FUNCTION 'BDC_OPEN_GROUP'
       EXPORTING
         CLIENT                    = SY-MANDT
         GROUP                     = LV_SESNAM
         HOLDDATE                  = '20040805'
         KEEP                      = 'X'
         USER                      = SY-UNAME
         PROG                      = SY-CPROG
    *  IMPORTING
    *    QID                       =
       EXCEPTIONS
         CLIENT_INVALID            = 1
         DESTINATION_INVALID       = 2
         GROUP_INVALID             = 3
         GROUP_IS_LOCKED           = 4
         HOLDDATE_INVALID          = 5
         INTERNAL_ERROR            = 6
         QUEUE_ERROR               = 7
         RUNNING                   = 8
         SYSTEM_LOCK_ERROR         = 9
         USER_INVALID              = 10
         OTHERS                    = 11
      IF SY-SUBRC <> 0.
        WRITE :/ 'Session not open'.
      ENDIF.
    ENDFORM.                    " FORM_OPENSESSION
    *&      Form  FORM_INSERT
    *       fORM TO INSERT ERROR RECOED INTO A SESSION.
    FORM FORM_INSERT .
    *--Inserting the record into session.
      CALL FUNCTION 'BDC_INSERT'
        EXPORTING
          TCODE                  = 'FD01'
    *     POST_LOCAL             = NOVBLOCAL
    *     PRINTING               = NOPRINT
    *     SIMUBATCH              = ' '
    *     CTUPARAMS              = ' '
        TABLES
          DYNPROTAB              = IT_CUSTBDC
        EXCEPTIONS
          INTERNAL_ERROR         = 1
          NOT_OPEN               = 2
          QUEUE_ERROR            = 3
          TCODE_INVALID          = 4
          PRINTING_INVALID       = 5
          POSTING_INVALID        = 6
          OTHERS                 = 7
      IF SY-SUBRC <> 0.
        WRITE :/ 'Unable to insert the record'.
      ENDIF.
    ENDFORM.                    " FORM_INSERT
    *&      Form  FORM_CLOSESESS
    *       Form to Close the Open Session.
    FORM FORM_CLOSESESS .
      CALL FUNCTION 'BDC_CLOSE_GROUP'
        EXCEPTIONS
          NOT_OPEN    = 1
          QUEUE_ERROR = 2
          OTHERS      = 3.
      IF SY-SUBRC <> 0.
      ENDIF.
    ENDFORM.                    " FORM_CLOSESESS
    *&      Form  FORM_FORMATMSG
    *       Form to format messages.
    FORM FORM_FORMATMSG .
    *--Var to store the formatted msg.
      DATA : LV_MSG(255).
      CALL FUNCTION 'FORMAT_MESSAGE'
        EXPORTING
          ID        = SY-MSGID
          LANG      = SY-LANGU
          NO        = SY-MSGNO
          V1        = SY-MSGV1
          V2        = SY-MSGV2
          V3        = SY-MSGV3
          V4        = SY-MSGV4
        IMPORTING
          MSG       = LV_MSG
        EXCEPTIONS
          NOT_FOUND = 1
          OTHERS    = 2.
      IF SY-SUBRC = 0.
        WRITE :/ LV_MSG.
      ENDIF.
      ULINE.
    ENDFORM.                    " FORM_FORMATMSG
    *&      Form  form_writeop
    *       To write the totals and the session name.
    FORM FORM_WRITEOP .
      WRITE :/ 'Total Records Uploaded :',V_TLINES,
               / 'No of Error Records :',V_ELINES,
               / 'No of Success Records :',V_SLINES,
               / 'Name of the Session :',V_SESNAM.
      ULINE.
    ENDFORM.                    " form_writeop

  • How to print the Terms and Condition page ine the sap-script

    Hi experts,
                             i got the requirement that how to print the Terms and condition page in the script,i have the three pages, having the same main window, in the last of the main window(all three pages)  i have called the hard coded text(i.e so10 text), but when i am displaying the output  data get printed in the first page but i am getting the second page heading on the top of  the terms and condiions page. In all the three pages i  have the same main window, if i  make change in any window i will affect all the other main  windows.  so please suggest me how i need to go.HOW TO GET GRID OF THE TEXT ON THE TOP OF THE SECOND PAGE OF THE TERMS AND CONDITONS.
    like this i have called in the MAIN WINDOW
    /E : LAST ( IN ALL THREE PAGES)
           INCLUDE ZSD_INVOICE_TERMS TEXT OBJECT TEXT LANGUAGE EN.
    IN THE TCODE SO10
    NEW PAGE TERMS.
    1) TERM MS AND CONDITONS  TEXT.................................................
    FIRST->NEXT, NEXT->NEXT,,   TERMS--->TERMS.

    Hi,
    1. Create a new page by Name : LAST
    2. Identify the text element which will be the last element in the form in the debug mode.
    Mostly Ex: SUM, TOTAL, LAST etc.,
    3. the page linking should be
    First --> Next
    Next --> Next
    4. In the Text element identified in the step 3.
    Write the following code
    /: NEW PAGE  LAST
    /: INCLUDE the standard text created for the terms and conditions in SO10
    Check the syntax for the command but the logic will be the same.
    It should resolve your problem.

  • How to catch the error occurred in Integration Process, and then save it?

    1. how to catch the error occurred in Integration Process, and then save the detailed error message to the file?
    2. there are fault message type for inbound message interface, how to use the fault message type in IR?
    Thanks,
    Michael
    Message was edited by: Spring Tang
    inital
    Message was edited by: Spring Tang
    detailed message output
    Message was edited by: Spring Tang
    fault message type

    Hi Spring,
    If u give an exception step along with your Transformation Step, whenever some error occurs in your message mapping, this exception block wil be triggered.
    You can configure your exception block to do all exception processing that you want. This exception handling is like any other java Exceptio n Handler. You can do anything that you want in your exception handler block on the basis of your requirements.
    <i>If an exception is triggered at runtime, the system first searches for the relevant exception handler in surrounding blocks. If it does not find the correct exception handler, it continues the search in the next block in the block hierarchy.
    When the system finds the correct system handler, it stops all active steps in the block in which the exception handler is defined and then continues processing in the exception handler branch. Once the exception handler has finished processing, the process is continued after the block.
    If the system fails to find an exception handler, it terminates the integration process with an error.</i>
    Regards,
    Bhavesh

  • How to print the receipt details both on the console and on receipt

    Hi All
    In ORPOS, Can anybody know how to print the sale transaction details on receipt and console as well
    After configuring with printer we can print only on receipt, if we want both on receipt and console as well
    Appreciate your suggestions and ideas
    Regards
    Ramakrishna

    Hi Rama
    This would not be any configuration change
    You can print receipt in both pinter and console by adding a sysout just before string is sent for printing
    Regards
    Saurabh
    [email protected]

  • In cursor i have two queries where put the condition and how to print the d

    hi i have 2 tables 1 is emp(empid,empname,dept,grade)
    2 is salary(grade,salary)
    in cursor when ever grade is increased salary automatically increased
    in 2 diffrent queries where i will put the if condition and how to print the output.
    any one can please suggest me.
    finally my required out put is
    empid,empname,grade,salary
    thanks

    It is always helpful to provide the following:
    1. Oracle version (SELECT * FROM V$VERSION)
    2. Sample data in the form of CREATE / INSERT statements.
    3. Expected output
    4. Explanation of expected output (A.K.A. "business logic")
    5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to solve the error "The specified resource is reserved" when running with DAQmx And LabVIEW?

    How to solve the error "The specified resource is reserved" when running with DAQmx And LabVIEW?

    I hate "J term"
    OK I love the learning the students get.   And, I like helping them out!  But, as a former man who's got the varicose viens to prove he's spent time "behind the podium" (yeah, "behind the podium" puts 'em to sleep- songs and dances for the young'uns) come on! USE the tools you teach!
    Instructors invited to engage in the forums
    Jeff

Maybe you are looking for

  • Home Hub 3.0 vs Home Hub 2.0 packet loss

    So I upgraded the BT package that our family is on today, and with it came the Home Hub 3.0. Happy right? Better wireless, less connection problems etc... No. For some reason, since upgrading, I get random moments of massive packet loss. Up to 50% pa

  • No luck wtih Captivate Aggregator or Reload

    Hi Folks- I have a 9-sco course that I am trying to package to upload to SkillSoft.  tried using the Aggregator to publish zipped files but then I had to open the zips to add the pdfs and other materials that are linked to in the scos. The Aggregator

  • HT4623 can i update my IPOD that has ios 4.2.1 to a least 6.0

    can i update my IPOD that has IOS 4.2.1 to a operation system that is at least 6.0 or higher

  • Upgrading Macbook Pro 10.4.11 os x...

    Hi there! I have a few questions about upgrading my operating system. My system is as follows: 10.4.11 Tiger, Processor (2.2 GHz Intel Core 2 Duo), Memory (2 GB) I have a copy of 10.5 Leopard, as well as the one that follows, but I am worried if inst

  • HT4528 deleting unwanted apps

    I have an iphone 4.  How do I delete messages I no longer want?