Updating a DB table by a BDC session in background

Hi,
I need to  update a DB table with records using a BDC session. I need to run this session in background. But the Error Log I'm getting suggests that Table Maintenance is required for the same.
Note that I can very well insert records in this table thru se11 and also by running the session in foreground.
Is there any work-around for this issue?
Thanks.

Hi
If at all you are using any DOWNLOAD and UPLOAD related function modules you can't run the BDC program in the background.
If it is a Z table update you can create the table maintenance generator.
other wise you can do it.
You can run session in background.
Reward points if useful
Regards
Anji

Similar Messages

  • URGENT - HOW TO PROCESS A BDC SESSION (IN BACKGROUND) FROM INSIDE A REPORT

    Hi All,
    I have a requirement wherein I need to create a BDC session for mass update(from file) of one transaction and check if at all that update has taken place and proceed with the same session for another transaction.
    For this I need to know how to process the session in background in a report, so that if the processing is done, the next set of data to update a different transaction can happen.
    All inputs are welcome and highly valuable to me.
    If someone is unable to intrepret this, I'll detail it again.
    Thanks in advance,
    Vaishnavi Varadarajan

    Hi,
    1.Use RSBDCDRU is an exe pg.With this u can download the logs into local file.
    2.It will create the spool request .from there u can download or print.
    OtherWise:
    Use the code from the link below. U need to provide the session queue id as input and it will download the log to an excel file. U can change it to  ur reqmt.
    Re: BDC
    regards
    kiran

  • Process bdc session in Background

    Hi all,
    I have created a BDC Session, Now i want to process it in Foreground not in Background.
    I know taht we use report RSBDCSUB for background processing but don't know the procedure for Forground.
    Sugess.
    Points will be sured for valuable answers.
    Thanks
    Sanket sethi

    hi,
    if you want it to be done by program then try this which is done through program
    TABLES: LFA1,
            RF02K.
    TYPES: BEGIN OF TY_ITAB,
            LIFNR LIKE RF02K-LIFNR,
            KTOKK LIKE RF02K-KTOKK,
            NAME1 LIKE LFA1-NAME1,
            SORTL LIKE LFA1-SORTL,
            LAND1 LIKE LFA1-LAND1,
            SPRAS LIKE LFA1-SPRAS,
            END OF TY_ITAB.
    DATA: T_ITAB TYPE TABLE OF TY_ITAB,
           W_ITAB TYPE TY_ITAB.
    DATA: I_BDCDATA TYPE TABLE OF BDCDATA,
           WA_BDCDATA TYPE BDCDATA.
    DATA : ITAB1 LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
    DATA : JOBNAME(32) TYPE C,
            JOBCOUNT(8) TYPE C.
    DATA: R1 TYPE I VALUE 1,
           C1 TYPE I VALUE 1,
           R2 TYPE I VALUE 4,
           C2 TYPE I VALUE 8,
           FILEPATH LIKE RLGRAP-FILENAME.
    SELECTION-SCREEN: BEGIN OF BLOCK B1.
    PARAMETERS:P_SRCFIL LIKE RLGRAP-FILENAME.
    SELECTION-SCREEN: END OF BLOCK B1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_SRCFIL.
    PERFORM SELECT_FILE USING P_SRCFIL.
    START-OF-SELECTION.
    FILEPATH = P_SRCFIL.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
       EXPORTING
         FILENAME                      = FILEPATH
         I_BEGIN_COL                   = 1
         I_BEGIN_ROW                   = 1
         I_END_COL                     = 8
         I_END_ROW                     = 4
       TABLES
         INTERN                        = ITAB1.
    PERFORM ORGANIZE_UPLOADED_DATA.
    CALL FUNCTION 'BDC_OPEN_GROUP'
      EXPORTING
        CLIENT                    = SY-MANDT
       DEST                      = FILLER8
        GROUP                      = 'XK01'
       HOLDDATE                  = FILLER8
        KEEP                       = 'X'
        USER                       = SY-UNAME.
    LOOP AT T_ITAB INTO W_ITAB.
    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'
    W_ITAB-LIFNR.
    PERFORM BDC_FIELD USING 'RF02K-KTOKK'
    W_ITAB-KTOKK.
    PERFORM BDC_DYNPRO USING 'SAPMF02K' '0110'.
    PERFORM BDC_FIELD USING 'BDC_CURSOR'
    'LFA1-SPRAS'.
    PERFORM BDC_FIELD USING 'BDC_OKCODE'
    '/00'.
    PERFORM BDC_FIELD USING 'LFA1-NAME1'
    W_ITAB-NAME1.
    PERFORM BDC_FIELD USING 'LFA1-SORTL'
    W_ITAB-SORTL.
    PERFORM BDC_FIELD USING 'LFA1-LAND1'
    W_ITAB-LAND1.
    PERFORM BDC_FIELD USING 'LFA1-SPRAS'
    W_ITAB-SPRAS.
    PERFORM BDC_DYNPRO USING 'SAPMF02K' '0120'.
    PERFORM BDC_FIELD USING 'BDC_CURSOR'
    'LFA1-KUNNR'.
    PERFORM BDC_FIELD USING 'BDC_OKCODE'
    '/00'.
    PERFORM BDC_DYNPRO USING 'SAPMF02K' '0130'.
    PERFORM BDC_FIELD USING 'BDC_CURSOR'
    'LFBK-BANKS(01)'.
    PERFORM BDC_FIELD USING 'BDC_OKCODE'
    '=ENTR'.
    PERFORM BDC_DYNPRO USING 'SAPMF02K' '0380'.
    PERFORM BDC_FIELD USING 'BDC_CURSOR' 'KNVK-NAMEV(01)'.
    PERFORM BDC_FIELD USING 'BDC_OKCODE' '=ENTR'.
    CLEAR W_ITAB.
    CALL FUNCTION 'BDC_INSERT'
    EXPORTING
       TCODE                   = 'XK01'
      TABLES
        DYNPROTAB              = I_BDCDATA.
      REFRESH I_BDCDATA.
    ENDLOOP.
    CALL FUNCTION 'BDC_CLOSE_GROUP' .
    JOBNAME = 'JOB'.
      CALL FUNCTION 'JOB_OPEN'
        EXPORTING
      DELANFREP              = ' '
      JOBGROUP               = ' '
          JOBNAME                = JOBNAME
    IMPORTING
       JOBCOUNT               = JOBCOUNT
    CHANGING
      RET                    =
    EXCEPTIONS
      CANT_CREATE_JOB        = 1
      INVALID_JOB_DATA       = 2
      JOBNAME_MISSING        = 3
      OTHERS                 = 4
      IF SY-SUBRC = 0.
       MESSAGE I000(0)      WITH 'SUCCESSFUL JOB OPENING'.
    SUBMIT RSBDCSUB
    WITH MAPPE = 'XK01'
    WITH VON = SY-DATUM
    *WITH Z_VERARB = 'X'
    WITH ERR = 'X'
    WITH LOGALL = 'X'
    AND RETURN EXPORTING LIST TO MEMORY.
    ENDIF.
    CALL FUNCTION 'JOB_CLOSE'
        EXPORTING
          JOBCOUNT                          = JOBCOUNT
          JOBNAME                           = JOBNAME
    EXCEPTIONS
       CANT_START_IMMEDIATE              = 1
       INVALID_STARTDATE                 = 2
       JOBNAME_MISSING                   = 3
       JOB_CLOSE_FAILED                  = 4
       JOB_NOSTEPS                       = 5
       JOB_NOTEX                         = 6
       LOCK_FAILED                       = 7
       INVALID_TARGET                    = 8
       OTHERS                            = 9
      IF SY-SUBRC <> 0.
       MESSAGE I000(0)   WITH 'JOBCLOSE'.
    ENDIF.
    *&      Form  ORGANIZE_UPLOADED_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM ORGANIZE_UPLOADED_DATA .
    SORT ITAB1 BY ROW COL.
    LOOP AT ITAB1.
    CASE ITAB1-COL.
    WHEN 1.
    W_ITAB-LIFNR = ITAB1-VALUE.
    WHEN 2.
    W_ITAB-KTOKK = ITAB1-VALUE.
    WHEN 3.
    W_ITAB-NAME1 = ITAB1-VALUE.
    WHEN 4.
    W_ITAB-SORTL = ITAB1-VALUE.
    WHEN 5.
    W_ITAB-LAND1 = ITAB1-VALUE.
    WHEN 6.
    W_ITAB-SPRAS = ITAB1-VALUE.
    ENDCASE.
    AT END OF ROW.
    APPEND W_ITAB TO T_ITAB.
    CLEAR W_ITAB.
    ENDAT.
    ENDLOOP.
    ENDFORM.                    " ORGANIZE_UPLOADED_DATA
    *&      Form  select_file
          text
         -->P_P_SRCFIL  text
    FORM SELECT_FILE  USING    P_SRCFIL.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
       PROGRAM_NAME        = SYST-CPROG
       DYNPRO_NUMBER       = SYST-DYNNR
       FIELD_NAME          = ' '
    IMPORTING
       FILE_NAME           = P_SRCFIL
    ENDFORM.                    " select_file
    *&      Form  bdc_dynpro
          text
         -->P_0131   text
         -->P_0132   text
    FORM BDC_DYNPRO  USING   PROGRAM LIKE BDCDATA-PROGRAM DYNPRO LIKE BDCDATA-DYNPRO.
      CLEAR WA_BDCDATA.
      WA_BDCDATA-PROGRAM  = PROGRAM.
      WA_BDCDATA-DYNPRO   = DYNPRO.
      WA_BDCDATA-DYNBEGIN = 'X'.
      APPEND WA_BDCDATA TO I_BDCDATA.
    ENDFORM.                    " bdc_dynpro
    *&      Form  bdc_field
          text
         -->P_0136   text
         -->P_0137   text
    FORM BDC_FIELD  USING    FNAM LIKE BDCDATA-FNAM  FVAL TYPE ANY  .
        CLEAR WA_BDCDATA.
        WA_BDCDATA-FNAM = FNAM.
        WA_BDCDATA-FVAL = FVAL.
        APPEND WA_BDCDATA TO I_BDCDATA.
    ENDFORM.                    " bdc_field
    reward if useful,
    thanks and regards

  • Update data using table contol in bdc

    please anyone can help me in this code  i.e how to update the database yusing table control please make changes in my code if required
    this is my code
    report ZTEST_XK01
           no standard page heading line-size 255.
    *include bdcrecx1.
    ***************PARAMETERS DECLERATIONS*********
    PARAMETERS  : P_file type rlgrap-filename, P_FILE1 TYPE RLGRAP-FILENAME
    **************internal table decleration*******
    data : bdcdata type standard table of bdcdata with header line.
    data : begin of t_lfa1 occurs 0,
            lifnr like RF02K-LIFNR,
            BUKRS LIKE RF02K-BUKRS,
            EKORG LIKE RF02K-EKORG,
            KTOKK LIKE RF02K-KTOKK,
            ANRED LIKE LFA1-ANRED,
            NAME1 LIKE LFA1-NAME1,
            SORTL LIKE LFA1-SORTL,
            LAND1 LIKE LFA1-LAND1,
            AKONT LIKE LFB1-AKONT,
            ZTERM LIKE LFB1-ZTERM,
           END OF T_LFA1.
    DATA : BEGIN OF T_LFBK OCCURS 0,
             BANKS LIKE LFBK-BANKS,
             BANKL LIKE LFBK-BANKL,
            END OF T_LFBK.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
       PROGRAM_NAME        = SYST-CPROG
       DYNPRO_NUMBER       = SYST-DYNNR
    FIELD_NAME          = ' '
    IMPORTING
       FILE_NAME           = p_FILE
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE1.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
       PROGRAM_NAME        = SYST-CPROG
       DYNPRO_NUMBER       = SYST-DYNNR
      FIELD_NAME          = ' '
    IMPORTING
       FILE_NAME           = P_FILE1
    start-of-selection.
    data : v_file type string.
    move p_file to v_file.
    data : e_file type string.
    move p_file1 to e_file.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      = v_file
       FILETYPE                      = 'ASC'
       HAS_FIELD_SEPARATOR           = 'X'
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
      VIRUS_SCAN_PROFILE            =
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      TABLES
        DATA_TAB                      = T_LFA1
    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.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      = E_FILE
       FILETYPE                      = 'ASC'
       HAS_FIELD_SEPARATOR           = 'X'
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
      VIRUS_SCAN_PROFILE            =
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      TABLES
        DATA_TAB                      = T_LFBK
    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 t_lfa1.
    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'
                                  t_lfa1-lifnr.
    perform bdc_field       using 'RF02K-BUKRS'
                                  t_lfa1-bukrs.
    perform bdc_field       using 'RF02K-EKORG'
                                  t_lfa1-ekorg.
    perform bdc_field       using 'RF02K-KTOKK'
                                  t_lfa1-ktokk.
    perform bdc_dynpro      using 'SAPMF02K' '0110'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFA1-SORTL'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'LFA1-ANRED'
                                t_lfa1-anred.
    perform bdc_field       using 'LFA1-NAME1'
                                 t_lfa1-name1.
    perform bdc_field       using 'LFA1-SORTL'
                                 t_lfa1-sortl.
    perform bdc_field       using 'LFA1-LAND1'
                                 t_lfa1-land1.
    perform bdc_dynpro      using 'SAPMF02K' '0120'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFA1-KUNNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    loop at t_lfbk .
    data : val(2) type c.
    data :v_fil type c.
    concatenate 'lfbk-banks(' val  ')' into v_fil.
    perform bdc_field using v_fil
    t_lfbk-BANKS.
    concatenate 'lfbk-bankl(' val  ')' into v_fil.
    perform bdc_field using v_fil
    t_lfbk-BANKl.
    val = 01.
    val = val + 1.
    if val > 5.
    val = 5.
    perform bdc_dynpro      using 'SAPMF02K' '0130'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFBK-BANKL(val)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  'ENTR'.
    perform bdc_field       using 'LFBK-BANKL(val)'
                                  v_fil.
    perform bdc_field       using 'LFBK-BANKS(val)'
                                  v_fil.
    *perform bdc_field       using 'LFBK-BANKS(02)'
                                 'IN'.
    *perform bdc_field       using 'LFBK-BANKS(03)'
                                 'in'.
    *perform bdc_field       using 'LFBK-BANKS(04)'
                                 'in'.
    *perform bdc_field       using 'LFBK-BANKS(05)'
                                 'in'.
    *perform bdc_field       using 'LFBK-BANKL(02)'
                                 '00000142'.
    *perform bdc_field       using 'LFBK-BANKL(03)'
                                 'sunny'.
    *perform bdc_field       using 'LFBK-BANKL(04)'
                                 'sunny'.
    *perform bdc_field       using 'LFBK-BANKL(05)'
                                 'sunny'.
    *perform bdc_dynpro      using 'SAPMF02K' '0130'.
    *perform bdc_field       using 'BDC_CURSOR'
                                 'LFBK-BANKS(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                   '=ENTR'.
    endif.
    endloop.
    perform bdc_dynpro      using 'SAPMF02K' '0210'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFB1-AKONT'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'LFB1-AKONT'
                                  '160000'.
    perform bdc_dynpro      using 'SAPMF02K' '0215'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFB1-ZTERM'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'LFB1-ZTERM'
                                  '0001'.
    perform bdc_dynpro      using 'SAPMF02K' '0220'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFB5-MAHNA'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPMF02K' '0310'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFM1-WAERS'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPMF02K' '0320'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RF02K-LIFNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_dynpro      using 'SAPLSPO1' '0300'.
    perform bdc_field       using 'BDC_OKCODE'

    Hi,
    you can check the following piece of code.
    *Batchinputdata of single transaction
    DATA :   tbl_bdcdata LIKE bdcdata   OCCURS 0 WITH HEADER LINE.
    *Input records
    DATA : BEGIN  OF tbl_input OCCURS 0,
           lifnr     LIKE     lfa1-lifnr,   "Account number of vendor or
           banks     LIKE     lfbk-banks,   "Bank country key
           bankl     LIKE     lfbk-bankl,   "Bank key
           bankn     LIKE     lfbk-bankn,   "Bank account number
           koinh LIKE    lfbk-koinh,   "Account holder name
           bvtyp     LIKE     lfbk-bvtyp,   "Partner bank type
           banka     LIKE     bnka-banka,   "Name of bank
           stcd3     LIKE     lfa1-stcd3,   "Tax number 3
           scacd     LIKE     lfa1-scacd,   "Standard carrier access code
           zwels     LIKE     lfb1-zwels,   "List of the Payment Methods to be
                                       "Considered
           lnrzb     LIKE     lfb1-lnrzb,   "Alternate payee
           iban     LIKE     tiban-iban,   "IBAN (International Bank Account
                                       "      Number)
           valid_from(10) TYPE c,      "Start of IBAN validity
           swift     LIKE     bnka-swift,   "SWIFT Code for International
                                       "Payments
           bukrs  LIKE zgroup_code_xref-bukrs,
                                       "Company code
           land1  LIKE t001-land1,     "Country
           END   OF tbl_input.
    *Constants
    *CONSTANTS
    CONSTANTS: c_tcode TYPE tstc-tcode VALUE 'XK02',   "For holding
                                                       "the TCODE
               c_keep(1) TYPE c VALUE 'X',                "To hold X
               c_tabctrl    TYPE i VALUE '6',             "For holding
               c_and        TYPE c VALUE '&',
               c_tab TYPE x VALUE '09'.
             START-OF-SELECTION                                         *
    START-OF-SELECTION.
      IF p_appser NE 'X' .
    *Download from presentation server
        PERFORM pres_file_download .
      ELSE.
    *Download from application server
        PERFORM appl_file_download.
      ENDIF.
      DESCRIBE TABLE tbl_input LINES w_rec.
    *Banking details upload
      IF  p_bank = 'X'.
        IF NOT tbl_input[] IS INITIAL.
          PERFORM data_fetching.
        ELSE.
          WRITE : text-017.
          EXIT.
        ENDIF.
        PERFORM data_validation.
        PERFORM final_data_prep.
        IF p_test NE 'X'.
        <b>  PERFORM bdc_data_load</b>.
        ENDIF.
    *Linking alternate payee
      ELSE.
        IF NOT tbl_input[] IS INITIAL.
          PERFORM data_fetching_zalt.
        ENDIF.
        PERFORM data_validation_zalt.
        PERFORM final_data_prep_zalt.
        PERFORM zalt_data_load.
      ENDIF.
    *&      <b>Form  bdc_data_load</b>
    FORM bdc_data_load.
      PERFORM open_group.
      DATA : l_cnt(2) TYPE n.                                   "TIR-70118
      SORT tbl_final BY lifnr bukrs.
      SORT tbl_lfbk BY lifnr.
      LOOP AT tbl_final.
        AT NEW bukrs.
          PERFORM 1_screen.
          PERFORM cursor_location.
        ENDAT.
        PERFORM table_control.
        l_cnt = l_cnt + 1.                                      "TIR-70118
        AT END OF bukrs.
    *Begin of addition for TIR-70118
          MOVE l_cnt TO tbl_lfbk-cnt.
          tbl_lfbk-lifnr = tbl_final-lifnr.
          COLLECT tbl_lfbk.
          SORT tbl_lfbk BY lifnr.
          CLEAR l_cnt.
    *End of addition for TIR-70118
          PERFORM last_screen.
          PERFORM insert_bdc.
          REFRESH tbl_bdcdata.
        ENDAT.
      ENDLOOP.
      PERFORM close_group.
    ENDFORM.                    " bdc_data_load
    *&    <b>  Form  1_screen</b>
    FORM 1_screen.
      PERFORM bdc_dynpro      USING 'SAPMF02K' '0101'.
      PERFORM bdc_field   USING : 'BDC_CURSOR'
                                  'RF02K-D0215',
                                    'BDC_OKCODE'
                                    '/00',
                                    'RF02K-LIFNR'
                                    tbl_final-lifnr,
                                    'RF02K-BUKRS'
                                     tbl_final-bukrs,
                                    'RF02K-D0110'
                                    'RF02K-D0120'
                                    'X',
                                   'RF02K-D0130'
                                    'X',
                                   'RF02K-D0215'
                                    'X'.
      PERFORM bdc_dynpro  USING 'SAPMF02K' '0120'.
      PERFORM bdc_field   USING :   'BDC_CURSOR'
                                    'LFA1-TXJCD',
                                    'BDC_OKCODE'
                                    '/00'.
    *Begin of changes for TIR-70118
      IF NOT tbl_final-stcd3 IS INITIAL.
        PERFORM bdc_field   USING :   'LFA1-STCD3'
                                      tbl_final-stcd3.
      ENDIF.
      IF NOT tbl_final-scacd IS INITIAL.
        PERFORM bdc_field   USING :   'LFA1-SCACD'
                                      tbl_final-scacd.
      ENDIF.
    *End of changes for TIR-70118
      PERFORM bdc_dynpro      USING 'SAPMF02K' '0130'.
    ENDFORM.                                                    " 1_screen
    *&     <b> Form  cursor_location</b>
    FORM cursor_location.
      DATA : l_times TYPE i.
      CLEAR tbl_lfbk.                                           "TIR-70118
      READ TABLE tbl_lfbk WITH KEY lifnr = tbl_final-lifnr
                                                 BINARY SEARCH.
      IF sy-subrc = 0.
        l_times = tbl_lfbk-cnt DIV 5.
        w_count = ( tbl_lfbk-cnt MOD 5 ) + 1.
        DO l_times TIMES.
          PERFORM page_down.
        ENDDO.
      ELSE.
        w_count = 1.
      ENDIF.
      CLEAR l_times.
    ENDFORM.                    " cursor_location
    *&   <b>   Form  table_control</b>
    FORM table_control.
      CONCATENATE 'LFBK-BANKS(' w_count ')'
                                       INTO w_fld1.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                                   w_fld1.
      CLEAR w_fld1.
      IF NOT ( tbl_final-banks IS INITIAL ).                    "TIR-70118
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=ENTR'.
        CONCATENATE 'LFBK-BANKS(' w_count ')'
                                         INTO w_fld1.
        PERFORM bdc_field       USING w_fld1
                                        tbl_final-banks.
        CLEAR w_fld1.
        CONCATENATE 'LFBK-BANKL(' w_count ')'
                                         INTO w_fld1.
        PERFORM bdc_field       USING w_fld1
                                        tbl_final-bankl.
        CLEAR w_fld1.
        CONCATENATE 'LFBK-BANKN(' w_count ')'
                                         INTO w_fld1.
        PERFORM bdc_field       USING  w_fld1
                                       tbl_final-bankn.
        CONCATENATE 'LFBK-KOINH(' w_count ')'
                                         INTO w_fld1.
        PERFORM bdc_field       USING w_fld1
                                         tbl_final-koinh.
        CONCATENATE 'LFBK-BKONT(' w_count ')'
                                         INTO w_fld1.
        PERFORM bdc_field       USING w_fld1
                                        tbl_final-bkont.
        CONCATENATE 'LFBK-BVTYP(' w_count ')'
                                         INTO w_fld1.
        PERFORM bdc_field       USING w_fld1
                                        tbl_final-bvtyp.
        CONCATENATE 'LFBK-BKREF(' w_count ')'
                                         INTO w_fld1.
        PERFORM bdc_field       USING w_fld1
                                       tbl_final-bkref.
        CLEAR w_fld1.
        IF NOT tbl_final-swift IS INITIAL.
          PERFORM swift_screen.
        ENDIF.
        IF NOT tbl_final-iban IS INITIAL.
          PERFORM iban_screen.
        ENDIF.
        PERFORM bdc_dynpro      USING 'SAPMF02K' '0130'.
    <b>    w_count = w_count + 1.
        IF w_count EQ c_tabctrl.
          w_count = 1.
          PERFORM page_down</b>.
        ENDIF.
      ENDIF.                                                   
    ENDFORM.                    " table_control
    *&  <b>    Form  page_down</b>
    FORM page_down.
      PERFORM bdc_field   USING 'BDC_OKCODE'
                                '=P+'.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                              'LFBK-BANKS(01)'.
      PERFORM bdc_dynpro  USING 'SAPMF02K'
                                '0130'.
      PERFORM bdc_field   USING 'BDC_OKCODE'
                                '/00'.
    ENDFORM.                    " page_down
    *&      Form  <b>Insert_BDC</b>
          This form takes the transaction code and populates the data
    FORM submit_bdc .
    **Function module that takes the TCODE and populate the data
      CALL FUNCTION 'BDC_INSERT'
           EXPORTING
                tcode            = c_tcode
           TABLES
                dynprotab        = tbl_bdcdata
           EXCEPTIONS
                internal_error   = 1
                not_open         = 2
                queue_error      = 3
                tcode_invalid    = 4
                printing_invalid = 5
                posting_invalid  = 6
                OTHERS           = 7.
    *Incase of error while populatin data
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                      "End of Submit_bdc
    I think this code can help for you, let me know if any doubts.
    Reward with points, if it helpful for u.
    Regards,
    Vijay

  • BDC Session in background

    Hi...
    I write a BDC Program using Session method.
    Now the requirement is , it should be run every 1 hour in background..
    Can U Please tell me the procedure to do this background process.
    Thanks in advance
    Ganesh Reddy

    Hello,
    Search in sap formus you will find the options
    https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_all&query=bdcSessioninbackground+&adv=false&sortby=cm_rnd_rankvalue

  • Program To Update BDC Session Status in SM35

    Existing Process : Currently we create orders using a function module which internally uses BDC Session method for transaction VA01. If the session ran successfully then we check the status and use SAVE_TEXT to upload the long text for the order. But in some cases the order fails. Then the session will be errored out in SM35 and user runs the session manually and fixes the problem and post order. So the text cannot be uploaded now as the user ran the session manually. So I wrote a Z program to run the session using program RSBDCCTU which the runs the session in forground and get the text from memory which I exported to memory while initial transaction and upload it using SAVE_TEXT after the session ran successfully. This program works fine.
    Problem : After running my Z program the order is posted and text is uploaded but the session is still in error status in SM35. The standard program RSBDCCTU just runs the session in foreground but does not update the status.
    Is there any other way we can do this or any other standard programs available to update the status of the session.
    Any help will be appreciated.

    How are you importing text in the z program, which is exported in the function module? they are totally unrelated internal sessions.
    You can as well import text and use SAVE_TEXT using user exit USEREXIT_SAVE_DOCUMENT_PREPARE in include MV45AFZZ after executing the error session in SM35, you don't need a Z program.
    Use condition SY-BINPT = 'X' and  T180-TRTYP = 'H' in the user exit to process SAVE_TEXT.
    Regards
    Sridhar

  • How can we use TABLE CONTROL in BDC and WORK FLOW of ABAP.

    how can we use TABLE CONTROL in BDC and WORK FLOW of ABAP.?
    please explain the important questions.

    How to deal with table control / step loop in BDC
    Steploop and table contol is inevitable in certain transactions. When we run BDC for such transactions, we will face the situation: how many visible lines of steploop/tablecontrol are on the screen? Although we can always find certain method to deal with it, such as function code 'NP', 'POPO', considering some extreme situation: there is only one line visible one the screen, our BDC program should display an error message. (See transaction 'ME21', we you resize your screen to let only one row visible, you can not enter mutiple lines on this screen even you use 'NP')
    Now with the help of Poonam on sapfans.com developement forum, I find a method with which we can determine the number of visible lines on Transaction Screen from our Calling BDC program. Maybe it is useless to you, but I think it will give your some idea.
    Demo ABAP code has two purposes:
    1. how to determine number of visible lines and how to calculte page number;
    (the 'calpage' routine has been modify to meet general purpose usage)
    2. using field symbol in BDC program, please pay special attention to the difference in Static ASSIGN and Dynamic ASSIGN.
    Now I begin to describe the step to implement my method:
    (I use transaction 'ME21', screen 121 for sample,
    the method using is Call Transation Using..)
    Step1: go to screen painter to display the screen 121, then we can count the fixed line on this screen, there is 7 lines above the steploop and 2 lines below the steploop, so there are total 9 fixed lines on this screen. This means except these 9 lines, all the other line is for step loop. Then have a look at steploop itselp, one entry of it will occupy two lines.
    (Be careful, for table control, the head and the bottom scroll bar will possess another two fixed lines, and there is a maximum number for table line)
    Now we have : FixedLine = 9
                  LoopLine  = 2(for table control, LoopLine is always equal to 1)
    Step2: go to transaction itself(ME21) to see how it roll page, in ME21, the first line of new page is always occupied by the last line of last page, so it begin with index '02', but in some other case, fisrt line is empty and ready for input.
    Now we have: FirstLine = 0
              or FirstLine = 1 ( in our case, FirstLine is 1 because the first line of new page is fulfilled)
    Step3: write a subroutine calcalculating number of pages
    (here, the name of actual parameter is the same as formal parameter)
    global data:    FixedLine type i, " number of fixed line on a certain screen
                    LoopLine  type i, " the number of lines occupied by one steploop item
                    FirstLine type i, " possbile value 0 or 1, 0 stand for the first line of new                                                               " scrolling screen is empty, otherwise is 1
                    Dataline  type i, " number of items you will use in BDC, using DESCRIBE to get
                    pageno    type i, " you need to scroll screen how many times.
                    line      type i, " number of lines appears on the screen.
                    index(2)  type N, " the screen index for certain item
                    begin     type i, " from parameter of loop
                    end       type i. " to parameter of loop
    *in code sample, the DataTable-linindex stands for the table index number of this line
    form calpage using FixedLine type i (see step 1)
                       LoopLine  type i (see step 1)
                       FirstLine type i (see step 2)
                       DataLine  type i ( this is the item number you will enter in transaction)
              changing pageno    type i (return the number of page, depends on run-time visible                                                                             line in table control/ Step Loop)
              changing line      type i.(visible lines one the screen)
    data: midd type i,
          vline type i, "visible lines
    if DataLine eq 0.
       Message eXXX.
    endif.
    vline = ( sy-srows - FixedLine ) div LoopLine.
    *for table control, you should compare vline with maximum line of
    *table control, then take the small one that is min(vline, maximum)
    *here only illustrate step loop
    if FirstLine eq 0.
            pageno = DataLine div vline.
            if pageno eq 0.
               pageno = pageno + 1.
            endif.
    elseif FirstLine eq 1.
            pageno = ( DataLine - 1 ) div ( vline - 1 ) + 1.
            midd = ( DataLine - 1 ) mod ( vline - 1).
            if midd = 0 and DataLine gt 1.
                    pageno = pageno - 1.
            endif.
    endif.
    line = vline.
    endform.
    Step4 write a subroutine to calculate the line index for each item.
    form calindex using Line type i (visible lines on the screen)
                        FirstLine type i(see step 2)
                        LineIndex type i(item index)
              changing  Index type n.    (index on the screen)
      if  FirstLine = 0.
            index = LineIndex mod Line.
            if index = '00'.
                    index = Line.
            endif.
      elseif FirstLine = 1.
            index = LineIndex mod ( Line - 1 ).
            if ( index between 1 and 0 ) and LineIndex gt 1.
                    index = index + Line - 1.
            endif.
            if Line = 2.
                    index = index + Line - 1.
            endif.
    endif.
    endform.
    Step5 write a subroutine to calculate the loop range.
    form calrange using Line type i ( visible lines on the screen)
                        DataLine type i
                        FirstLine type i
                        loopindex like sy-index
            changing    begin type i
                        end type i.
    If FirstLine = 0.
       if loopindex = 1.
            begin = 1.
            if DataLine <= Line.
                    end = DataLine.
            else.
                    end = Line.
            endif.
       elseif loopindex gt 1.
            begin = Line * ( loopindex - 1 ) + 1.
            end   = Line * loopindex.
            if end gt DataLine.
               end = DataLine.
            endif.
       endif.
    elseif FirstLine = 1.
      if loopindex = 1.
            begin = 1.
            if DataLine <= Line.
                    end = DataLine.
            else.
                    end = Line.
            endif.
      elseif loop index gt 1.
            begin = ( Line - 1 ) * ( loopindex - 1 ) + 2.
            end =   ( Line - 1 ) * ( loopindex - 1 ) + Line.
            if end gt DataLine.
                    end = DataLine.
            endif.
      endif.
    endif.
    endform.
    Step6 using field sysbol in your BDC, for example: in ME21, but you should calculate each item will correponding to which index in steploop/Table Control
    form creat_bdc.
    field-symbols: <material>, <quan>, <indicator>.
    data: name1(14) value 'EKPO-EMATN(XX)',
          name2(14) value 'EKPO-MENGE(XX)',
          name3(15) value 'RM06E-SELKZ(XX)'.
    assign:         name1 to <material>,
                    name2 to <quan>,
                    name3 to <indicator>.
    do pageno times.
    if sy-index gt 1
    *insert scroll page ok_code"
    endif.
            perform calrange using Line DataLine FirstLine sy-index
                             changing begin end.
    loop at DataTable from begin to end.
            perform calindex using Line FirstLine DataTable-LineIndex changing Index.
            name1+11(2) = Index.
            name2+11(2) = Index.
            name3+12(2) = Index.
            perform bdcfield using <material> DataTable-matnr.
            perform bdcfield using <quan>     DataTable-menge.
            perform bdcfield using <indicator> DataTable-indicator.
    endloop.
    enddo.
    An example abap program of handling Table Control during bdc programming.
    REPORT zmm_bdcp_purchaseorderkb02
           NO STANDARD PAGE HEADING LINE-SIZE 255.
                    Declaring internal tables                            *
    *-----Declaring line structure
    DATA : BEGIN OF it_dummy OCCURS 0,
             dummy(255) TYPE c,
           END OF it_dummy.
    *-----Internal table for line items
    DATA :  BEGIN OF it_idata OCCURS 0,
              ematn(18),      "Material Number.
              menge(13),      "Qyantity.
              netpr(11),      "Net Price.
              werks(4),       "Plant.
              ebelp(5),       "Item Number.
            END OF it_idata.
    *-----Deep structure for header data and line items
    DATA  :  BEGIN OF it_me21 OCCURS 0,
               lifnr(10),      "Vendor A/c No.
               bsart(4),       "A/c Type.
               bedat(8),       "Date of creation of PO.
               ekorg(4),       "Purchasing Organisation.
               ekgrp(3),       "Purchasing Group.
               x_data LIKE TABLE OF it_idata,
             END OF it_me21.
    DATA  :  x_idata LIKE LINE OF it_idata.
    DATA  :  v_delimit VALUE ','.
    DATA  :  v_indx(3) TYPE n.
    DATA  :  v_fnam(30) TYPE c.
    DATA  :  v_count TYPE n.
    DATA  :  v_ne TYPE i.
    DATA  :  v_ns TYPE i.
    *include bdcrecx1.
    INCLUDE zmm_incl_purchaseorderkb01.
                    Search help for file                                 *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          program_name  = syst-cprog
          dynpro_number = syst-dynnr
        IMPORTING
          file_name     = p_file.
    START-OF-SELECTION.
           To upload the data into line structure                        *
      CALL FUNCTION 'WS_UPLOAD'
        EXPORTING
          filename = p_file
          filetype = 'DAT'
        TABLES
          data_tab = it_dummy.
        Processing the data from line structure to internal tables       *
      REFRESH:it_me21.
      CLEAR  :it_me21.
      LOOP AT it_dummy.
        IF it_dummy-dummy+0(01) = 'H'.
          v_indx = v_indx + 1.
          CLEAR   it_idata.
          REFRESH it_idata.
          CLEAR   it_me21-x_data.
          REFRESH it_me21-x_data.
          SHIFT it_dummy.
          SPLIT it_dummy AT v_delimit INTO it_me21-lifnr
                                           it_me21-bsart
                                           it_me21-bedat
                                           it_me21-ekorg
                                           it_me21-ekgrp.
          APPEND it_me21.
        ELSEIF it_dummy-dummy+0(01) = 'L'.
          SHIFT it_dummy.
          SPLIT it_dummy AT v_delimit INTO it_idata-ematn
                                           it_idata-menge
                                           it_idata-netpr
                                           it_idata-werks
                                           it_idata-ebelp.
          APPEND it_idata TO it_me21-x_data.
          MODIFY it_me21 INDEX v_indx.
        ENDIF.
      ENDLOOP.
                    To open the group                                    *
      PERFORM open_group.
            To populate the bdcdata table for header data                *
      LOOP AT it_me21.
        v_count = v_count + 1.
        REFRESH it_bdcdata.
        PERFORM subr_bdc_table USING:   'X' 'SAPMM06E'    '0100',
                                        ' ' 'BDC_CURSOR'  'EKKO-LIFNR',
                                        ' ' 'BDC_OKCODE'  '/00',
                                        ' ' 'EKKO-LIFNR'  it_me21-lifnr,
                                        ' ' 'RM06E-BSART' it_me21-bsart,
                                        ' ' 'RM06E-BEDAT' it_me21-bedat,
                                        ' ' 'EKKO-EKORG'  it_me21-ekorg,
                                        ' ' 'EKKO-EKGRP'  it_me21-ekgrp,
                                        ' ' 'RM06E-LPEIN' 'T'.
        PERFORM subr_bdc_table USING:   'X' 'SAPMM06E'    '0120',
                                        ' ' 'BDC_CURSOR'  'RM06E-EBELP',
                                        ' ' 'BDC_OKCODE'  '/00'.
        MOVE 1 TO v_indx.
    *-----To populate the bdcdata table for line item data
        LOOP AT it_me21-x_data INTO x_idata.
          CONCATENATE 'EKPO-EMATN(' v_indx ')'  INTO v_fnam.
          PERFORM  subr_bdc_table USING ' ' v_fnam x_idata-ematn.
          CONCATENATE 'EKPO-MENGE(' v_indx ')'  INTO v_fnam.
          PERFORM  subr_bdc_table USING ' ' v_fnam x_idata-menge.
          CONCATENATE 'EKPO-NETPR(' v_indx ')'  INTO v_fnam.
          PERFORM  subr_bdc_table USING ' ' v_fnam x_idata-netpr.
          CONCATENATE 'EKPO-WERKS(' v_indx ')'  INTO v_fnam.
          PERFORM  subr_bdc_table USING ' ' v_fnam x_idata-werks.
          v_indx = v_indx + 1.
          PERFORM subr_bdc_table USING:  'X' 'SAPMM06E'    '0120',
                                         ' ' 'BDC_CURSOR'  'RM06E-EBELP',
                                         ' ' 'BDC_OKCODE'  '/00'.
        ENDLOOP.
        PERFORM subr_bdc_table USING:    'X' 'SAPMM06E'    '0120',
                                         ' ' 'BDC_CURSOR'  'RM06E-EBELP',
                                         ' ' 'BDC_OKCODE'  '=BU'.
        PERFORM bdc_transaction USING 'ME21'.
      ENDLOOP.
      PERFORM close_group.
                      End of selection event                             *
    END-OF-SELECTION.
      IF session NE 'X'.
    *-----To display the successful records
        WRITE :/10  text-001.          "Sucess records
        WRITE :/10  SY-ULINE(20).
        SKIP.
        IF it_sucess IS INITIAL.
          WRITE :/  text-002.
        ELSE.
          WRITE :/   text-008,          "Total number of Succesful records
                  35 v_ns.
          SKIP.
          WRITE:/   text-003,          "Vendor Number
                 17 text-004,          "Record number
                 30 text-005.          "Message
        ENDIF.
        LOOP AT it_sucess.
          WRITE:/4  it_sucess-lifnr,
                 17 it_sucess-tabix CENTERED,
                 30 it_sucess-sucess_rec.
        ENDLOOP.
        SKIP.
    *-----To display the erroneous records
        WRITE:/10   text-006.          "Error Records
        WRITE:/10   SY-ULINE(17).
        SKIP.
        IF it_error IS INITIAL.
          WRITE:/   text-007.          "No error records
        ELSE.
          WRITE:/   text-009,          "Total number of erroneous records
                 35 v_ne.
          SKIP.
          WRITE:/   text-003,          "Vendor Number
                 17 text-004,          "Record number
                 30 text-005.          "Message
        ENDIF.
        LOOP AT it_error.
          WRITE:/4  it_error-lifnr,
                 17 it_error-tabix CENTERED,
                 30 it_error-error_rec.
        ENDLOOP.
        REFRESH it_sucess.
        REFRESH it_error.
      ENDIF.
    CODE IN INCLUDE.
    Include           ZMM_INCL_PURCHASEORDERKB01
    DATA:   it_BDCDATA LIKE BDCDATA    OCCURS 0 WITH HEADER LINE.
    DATA:   it_MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
    DATA:   E_GROUP_OPENED.
    *-----Internal table to store sucess records
    DATA:BEGIN OF it_sucess OCCURS 0,
           msgtyp(1)   TYPE c,
           lifnr  LIKE  ekko-lifnr,
           tabix  LIKE  sy-tabix,
           sucess_rec(125),
         END OF it_sucess.
    DATA: g_mess(125) type c.
    *-----Internal table to store error records
    DATA:BEGIN OF it_error OCCURS 0,
           msgtyp(1)   TYPE c,
           lifnr  LIKE  ekko-lifnr,
           tabix  LIKE  sy-tabix,
           error_rec(125),
         END OF it_error.
           Selection screen
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS session RADIOBUTTON GROUP ctu.  "create session
    SELECTION-SCREEN COMMENT 3(20) text-s07 FOR FIELD session.
    SELECTION-SCREEN POSITION 45.
    PARAMETERS ctu RADIOBUTTON GROUP ctu.     "call transaction
    SELECTION-SCREEN COMMENT 48(20) text-s08 FOR FIELD ctu.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 3(20) text-s01 FOR FIELD group.
    SELECTION-SCREEN POSITION 25.
    PARAMETERS group(12).                      "group name of session
    SELECTION-SCREEN COMMENT 48(20) text-s05 FOR FIELD ctumode.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS ctumode LIKE ctu_params-dismode DEFAULT 'N'.
    "A: show all dynpros
    "E: show dynpro on error only
    "N: do not display dynpro
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 48(20) text-s06 FOR FIELD cupdate.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS cupdate LIKE ctu_params-updmode DEFAULT 'L'.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 3(20) text-s03 FOR FIELD keep.
    SELECTION-SCREEN POSITION 25.
    PARAMETERS: keep AS CHECKBOX.       "' ' = delete session if finished
    "'X' = keep   session if finished
    SELECTION-SCREEN COMMENT 48(20) text-s09 FOR FIELD e_group.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS e_group(12).             "group name of error-session
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 51(17) text-s03 FOR FIELD e_keep.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS: e_keep AS CHECKBOX.     "' ' = delete session if finished
    "'X' = keep   session if finished
    SELECTION-SCREEN END OF LINE.
    PARAMETERS:p_file LIKE rlgrap-filename.
      at selection screen                                                *
    AT SELECTION-SCREEN.
    group and user must be filled for create session
      IF SESSION = 'X' AND
         GROUP = SPACE. "OR USER = SPACE.
        MESSAGE E613(MS).
      ENDIF.
      create batchinput session                                          *
    FORM OPEN_GROUP.
      IF SESSION = 'X'.
        SKIP.
        WRITE: /(20) 'Create group'(I01), GROUP.
        SKIP.
    *----open batchinput group
        CALL FUNCTION 'BDC_OPEN_GROUP'
          EXPORTING
            CLIENT = SY-MANDT
            GROUP  = GROUP
            USER   = sy-uname.
        WRITE:/(30) 'BDC_OPEN_GROUP'(I02),
                (12) 'returncode:'(I05),
                     SY-SUBRC.
      ENDIF.
    ENDFORM.                    "OPEN_GROUP
      end batchinput session                                             *
    FORM CLOSE_GROUP.
      IF SESSION = 'X'.
    *------close batchinput group
        CALL FUNCTION 'BDC_CLOSE_GROUP'.
        WRITE: /(30) 'BDC_CLOSE_GROUP'(I04),
                (12) 'returncode:'(I05),
                     SY-SUBRC.
      ELSE.
        IF E_GROUP_OPENED = 'X'.
          CALL FUNCTION 'BDC_CLOSE_GROUP'.
          WRITE: /.
          WRITE: /(30) 'Fehlermappe wurde erzeugt'(I06).
        ENDIF.
      ENDIF.
    ENDFORM.                    "CLOSE_GROUP
           Start new transaction according to parameters                 *
    FORM BDC_TRANSACTION USING TCODE TYPE ANY.
      DATA: L_SUBRC LIKE SY-SUBRC.
    *------batch input session
      IF SESSION = 'X'.
        CALL FUNCTION 'BDC_INSERT'
          EXPORTING
            TCODE     = TCODE
          TABLES
            DYNPROTAB = it_BDCDATA.
        WRITE: / 'BDC_INSERT'(I03),
                 TCODE,
                 'returncode:'(I05),
                 SY-SUBRC,
                 'RECORD:',
                 SY-INDEX.
      ELSE.
        REFRESH it_MESSTAB.
        CALL TRANSACTION TCODE USING it_BDCDATA
                         MODE   CTUMODE
                         UPDATE CUPDATE
                         MESSAGES INTO it_MESSTAB.
        L_SUBRC = SY-SUBRC.
        WRITE: / 'CALL_TRANSACTION',
                 TCODE,
                 'returncode:'(I05),
                 L_SUBRC,
                 'RECORD:',
                 SY-INDEX.
      ENDIF.
      Message handling for Call Transaction                              *
      perform subr_mess_hand using g_mess.
    *-----Erzeugen fehlermappe
      IF L_SUBRC <> 0 AND E_GROUP <> SPACE.
        IF E_GROUP_OPENED = ' '.
          CALL FUNCTION 'BDC_OPEN_GROUP'
            EXPORTING
              CLIENT = SY-MANDT
              GROUP  = E_GROUP
              USER   = sy-uname
              KEEP   = E_KEEP.
          E_GROUP_OPENED = 'X'.
        ENDIF.
        CALL FUNCTION 'BDC_INSERT'
          EXPORTING
            TCODE     = TCODE
          TABLES
            DYNPROTAB = it_BDCDATA.
      ENDIF.
      REFRESH it_BDCDATA.
    ENDFORM.                    "BDC_TRANSACTION
         Form  subr_bdc_table                                            *
          text
         -->P_0220   text                                                *
         -->P_0221   text                                                *
         -->P_0222   text                                                *
    FORM subr_bdc_table  USING      VALUE(P_0220) TYPE ANY
                                    VALUE(P_0221) TYPE ANY
                                    VALUE(P_0222) TYPE ANY.
      CLEAR it_bdcdata.
      IF P_0220 = ' '.
        CLEAR it_bdcdata.
        it_bdcdata-fnam     = P_0221.
        it_bdcdata-fval     = P_0222.
        APPEND it_bdcdata.
      ELSE.
        it_bdcdata-dynbegin = P_0220.
        it_bdcdata-program  = P_0221.
        it_bdcdata-dynpro   = P_0222.
        APPEND it_bdcdata.
      ENDIF.
    ENDFORM.                    " subr_bdc_table
         Form  subr_mess_hand                                            *
          text                                                           *
         -->P_G_MESS  text                                               *
    FORM subr_mess_hand USING  P_G_MESS TYPE ANY.
      LOOP AT IT_MESSTAB.
        CALL FUNCTION 'FORMAT_MESSAGE'
          EXPORTING
            ID     = it_messtab-msgid
            LANG   = it_messtab-msgspra
            NO     = it_messtab-msgnr
            v1     = it_messtab-msgv1
            v2     = it_messtab-msgv2
          IMPORTING
            MSG    = P_G_MESS
          EXCEPTIONS
            OTHERS = 0.
        CASE it_messtab-msgtyp.
          when 'E'.
            it_error-error_rec   =  P_G_MESS.
            it_error-lifnr       =  it_me21-lifnr.
            it_error-tabix       =  v_count.
            APPEND IT_ERROR.
          when 'S'.
            it_sucess-sucess_rec =  P_G_MESS.
            it_sucess-lifnr      =  it_me21-lifnr.
            it_sucess-tabix      =  v_count.
            APPEND IT_SUCESS.
        endcase.
      ENDLOOP.
      Describe table it_sucess lines v_ns.
      Describe table it_error  lines v_ne.
    ENDFORM.                    " subr_mess_hand
    Also refer
    http://sap.ittoolbox.com/groups/technical-functional/sap-dev/bdc-table-control-668404
    and
    http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
    Regards,
    srinivas
    <b>*reward for useful answers*</b>

  • ZXPADU02 - How To Stop It From Being Triggered in  a BDC Session

    I have an edit in ZXPADU02 that says if you are trying to change IT0167 you will get a POPUP Message telling you we don't want you doing that.   My problem is that I am using PA30 in a BDC session in another program to update IT167 and it is causing the User Exit to trigger the message, which gets an error because it can't display the POPUP.  Is there some way I can have this message NOT be triggered when I use PA30 in a BDC?

    Hi,
    You can one thing. When you are calling PA30 through BDC then you can populate some custom table with some value and in the exit check whether the custom table contains that value. If it contains then you can skip it. Other wise you can put keep some field vale in memory and then read the value from memory in the user exit.  Based on that you can modify your code.
    Thanks & Regards,
    Sandip

  • Back ground job bdc session

    Hai All,
    Can any one tell me how to catch the erros in BDC session method back ground job.
    I need to update Sales orders in BDC session, back ground job.
    Finally at the end I need to generate a report which contains all the succesfull updates & errors.
    I tried this using call transaction with messtab and is working fine.
    Please tell me how to do this in Session method.
    Thanks & Regards,
    Bhaskar.

    Hi Bhaskar,
    In Session method what you need to do is before processing of hte BDC first you need to check all the data. And if any error found then populate it into the internal table. And that internal table you need to display it on the output......
    I think this is the solution but I am not to sure........
    &********Reward Point if helpful*******&

  • About using rsbdcsub to run BDC session .

    Hi all,
    I use rsbdcsub to run a bdc session ,
    But the job created by the program is always in "ready" status and never run(complete) .
    How can I solve the problem?
    Thanks
    Pole
    Message was edited by: gw gw

    Hi Srinivas,
    Thanks very much.You understood what I meant exectly.
    Because the files provided by the several banks systems are not the same format,so we can not use the report RFEBKA00.And now we are developing the system connecting to the bank system directly,we can get the data from the bank and upload them to the sap system without creating a file.
    So we use the FF67 BDC
    The program like this:
    "it_data" is the internal table containing the data from the bank system.
    "l_mnam1" is the session name created by the program.
    PERFORM fill_bdcdata USING:
                      'SAPMF40K'            '0110'           'X',
                      'FEBMKA-FDIS_SEL'     'X'              ' ',
                      'FEBMKA-VARI_START'   'TKL01'          ' ',
                      'FEBMKA-DEBI_MID'     'D'              ' ',
                      'FEBMKA-KRED_MID'     'K'              ' ',
                      'FEBMKA-WVAR_ART'     '2'              ' ',
                      'FEBMKA-BUCH_VAL'     'X'              ' ',
                      'BDC_OKCODE'          '=ENTE'          ' ',
                      'SAPMF40K'            '0102'           'X',
                      'FEBMKA-BANKL'        t012-bankl       ' ',
                      'FEBMKA-BANKN'        t012k-bankn      ' ',
                      'FEBMKA-WAERS'        'CNY'            ' ',
                      'FEBMKA-AZNUM'        febko-aznum      ' ',
                      'FEBMKA-AZDAT'        l_azdat          ' ',
                      'FEBMKA-SSALD'        l_esbtr          ' ',
                      'FEBMKA-ESALD'        l_ssbtr          ' ',
                      'FEBMKA-BUDTM'        l_BUDTM          ' ',
                      'FEBMKA-MNAM1'        l_mnam1          ' ',
                      'BDC_OKCODE'          '/00'            ' ',
                      'SAPMF40K'            '8000'           'X'.
      SORT it_data BY valut.
      LOOP AT it_data.
        WRITE it_data-kwbtr TO l_kwbtr CURRENCY 'CNY'.
        l_zuonr = it_data-zuonr.
        PERFORM fill_bdcdata USING:
                      'FEBMKA-VGMAN(01)'    it_data-vgman    ' ',
                      'FEBEP-VALUT(01)'     it_data-valut    ' ',
                      'FEBMKA-KWBTR(01)'    l_kwbtr          ' ',
                      'FEBMKK-ZUONR_KF(01)' it_data-zuonr    ' ',
                      'FEBMKK-SGTXT_KF(01)' l_zuonr          ' ',
                      'BDC_OKCODE'          '=ZINS'          ' ',
                      'SAPMF40K'            '8000'           'X'.
        AT LAST.
          PERFORM fill_bdcdata USING:
                      'BDC_OKCODE'          '=SICH'          ' '.
        ENDAT.
      ENDLOOP.
      PERFORM fill_bdcdata USING:
                    'SAPMF40K'            '0102'           'X',
                    'BDC_OKCODE'          '=BUCH'          ' ',
                    'SAPMF40K'            '0102'           'X',
                    'BDC_OKCODE'          '/EENDE'         ' '.
      l_mode = 'N'.
      CALL TRANSACTION 'FF67' USING t_bdcdata MODE l_mode
                              UPDATE 'S'
                              MESSAGES INTO t_msg_tab.
    Thanks again for your help.
    Pole

  • Bdc session method

    Hi all ,
    where BDC_OK  fields  will store  in which table .
    and also how to reslove the screen resolution  in bdc session method .
    Regards ,
    Kiran .

    hi
    to maintain Screen Resolution just try this
    in the BDC Program source code u will find
    include BDCRECX1 just double click on it,u can see the selection screen of BDC
    and form definitions for Open_Group ,BdcTransaction & CloseGroup,since it is a std include program
    u cannot change it so copy this to a Z include and use that Z include instead of BDCRECX1
    Then go to form BDCTRANSACTION using TCODE
    in that form Declare a workarea(eg: opt) of structure type CTU_PARAMS
    data:   messtab like bdcmsgcoll occurs 0 with header line.
    data : opt type ctu_params.
    pass the values to it
    dismode-> Processing mode (A,E,N,P)
    updmode-> Update mode (L,S,A)
    defsize-> Default Screen Size (X) to maintain Screen Resolution
      opt-dismode = ctumode.
      opt-updmode = cupdate.
      opt-defsize = 'X'.
    if session = 'X'.
        call function 'BDC_INSERT'
         exporting
           tcode                  = tcode
           ctuparams              = 'OPT'
          tables
            dynprotab              = bdcdata.
    else.
        refresh messtab.
        call transaction tcode using bdcdata options from opt messages into messtab.
    endif.
    Regards

  • Question in BDC session method.

    Hi guys,
    I am trying to upload BOM using BDC session method.
    While doing this, i have learnt the steps by heart. But i do not understrand the logic behind the steps. For example, why do we include this statement
    Data: IT-BDC like BDCDATA occurs 0 with headerline.
    What if we don't include this statement?
    Moderator message: sorry, these forums are not targeted to provide step by step guides to beginners, please search for available information, take courses, etc.
    locked by: Thomas Zloch on Sep 10, 2010 1:06 PM

    Hello Dhirendra,
    Thanks for immediate reply. I want to understand BDC method conceptually. What exactly happens by performing each step.
    I am putting up the BDC i made. I copied some of the code from here and there. It works fine but i don't understand the purpose of BDCDATA,
    call transaction 'cs01'
    and form bdc_dynpro and form bdc_field.
    I am quite new to ABAP. Please don't mind if i ask dumb questions.
    I am unable to understand how control flows through the code logic.
    report ZBDCFORCS01
           no standard page heading line-size 255.
    *include bdcrecx1.
    DATA: IT_BDC LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
          IT_MSGCOLL LIKE BDCMSGCOLL OCCURS 0.
    TYPES TRUXS_T_TEXT_DATA(4096) TYPE C OCCURS 0.
    DATA: I_TAB_RAW_DATA TYPE TRUXS_T_TEXT_DATA.
    DATA: BEGIN OF ITAB OCCURS 0,
          MATNR(18),
          WERKS(4),
          STLAN(1),
          IDNRK(18),
          MENGE(20),
          END OF ITAB.
    SELECTION-SCREEN: BEGIN OF BLOCK b1.
      PARAMETERS: CS01FILE TYPE RLGRAP-FILENAME.
    SELECTION-SCREEN: END OF BLOCK b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR CS01FILE.
      CALL FUNCTION 'F4_FILENAME'
       EXPORTING
         PROGRAM_NAME        = SYST-CPROG
         DYNPRO_NUMBER       = SYST-DYNNR
         FIELD_NAME          = ' '
       IMPORTING
         FILE_NAME           = CS01FILE
    start-of-selection.
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
      EXPORTING
      I_FIELD_SEPERATOR          =
      I_LINE_HEADER              =
        I_TAB_RAW_DATA             = I_TAB_RAW_DATA
        I_FILENAME                 = CS01FILE
      TABLES
        I_TAB_CONVERTED_DATA       = ITAB[]
    EXCEPTIONS
       CONVERSION_FAILED          = 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.
    *perform open_group.
    LOOP AT ITAB.
    perform bdc_dynpro      using 'SAPLCSDI' '0100'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RC29N-STLAN'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'RC29N-MATNR'
                                 '1400-500'.
    itab-matnr.
    perform bdc_field       using 'RC29N-WERKS'
                                 '1000'.
    itab-werks.
    perform bdc_field       using 'RC29N-STLAN'
                                 '1'.
    itab-stlan.
    perform bdc_field       using 'RC29N-DATUV'
                                  '10.09.2010'.
    perform bdc_dynpro      using 'SAPLCSDI' '0110'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'RC29K-BMENG'
                                  '1'.
    perform bdc_field       using 'RC29K-STLST'
                                  '1'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RC29K-EXSTL'.
    perform bdc_dynpro      using 'SAPLCSDI' '0111'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RC29K-LABOR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPLCSDI' '0140'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RC29P-MENGE(02)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'RC29P-IDNRK(01)'
                                 '1300-320'.
    ITAB-IDNRK.
    perform bdc_field       using 'RC29P-IDNRK(02)'
                                 '1300-312'.
    ITAB-IDNRK.
    perform bdc_field       using 'RC29P-MENGE(01)'
                                 '2'.
    ITAB-MENGE.
    perform bdc_field       using 'RC29P-MENGE(02)'
                                 '2'.
    ITAB-MENGE.
    perform bdc_dynpro      using 'SAPLCSDI' '0130'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RC29P-POSNR'.
    perform bdc_field       using 'RC29P-POSNR'
                                  '0010'.
    perform bdc_field       using 'RC29P-IDNRK'
                                  '1300-320'.
    perform bdc_field       using 'RC29P-MENGE'
                                  '2'.
    perform bdc_field       using 'RC29P-MEINS'
                                  'PC'.
    perform bdc_dynpro      using 'SAPLCSDI' '0131'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RC29P-POTX1'.
    perform bdc_field       using 'RC29P-SANKA'
                                  'X'.
    perform bdc_dynpro      using 'SAPLCSDI' '0130'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RC29P-POSNR'.
    perform bdc_field       using 'RC29P-POSNR'
                                  '0020'.
    perform bdc_field       using 'RC29P-IDNRK'
                                  '1300-312'.
    perform bdc_field       using 'RC29P-MENGE'
                                  '2'.
    perform bdc_field       using 'RC29P-MEINS'
                                  'PC'.
    perform bdc_dynpro      using 'SAPLCSDI' '0131'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RC29P-POTX1'.
    perform bdc_field       using 'RC29P-SANKA'
                                  'X'.
    perform bdc_dynpro      using 'SAPLCSDI' '0140'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RC29P-POSNR(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPLCSDI' '0140'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RC29P-POSNR(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=FCBU'.
    perform bdc_transaction using 'CS01'.
    *perform close_group.
    CALL TRANSACTION 'CS01' USING IT_BDC
                MODE 'A'
                UPDATE 'S'
                MESSAGES INTO IT_MSGCOLL.
    REFRESH IT_BDC.           
    ENDLOOP.
    FORM BDC_DYNPRO USING PROGRAM_DYNPRO.
      CLEAR IT_BDC.
      BDCDATA-PROGRAM = PROGRAM.
      BDCDATA-DYNPRO = DYNPRO.
      BDCDATA-DYNBEGIN = 'X'.
      APPEND IT_BDC.
    ENDFORM.
    FORM BDC_FIELD USING FNAM FVAL.
      CLEAR BDCDATA.
      BDCDATA-FNAM = FNAM.
      BDCDATA-FVAL = FVAL.
      APPEND BDCDATA.
    ENDFORM.
    Edited by: Yayati6260 on Sep 10, 2010 12:29 PM

  • Incorrect state of bdc-sessions after system-termination

    Hello,
    following situation:
    I've run 8 bdc-sessions and system breaks down becaus of to less table space.
    After correction of table space and activating update (sm13)
    the job's go on.
    But 2 bdc-sessions have a false state - they show processing but sm50 and log shows that they do nothing. The creation of customers is not complete (only 50 %). How can I correct the state of the bdc-sessions and process the jobs further???
    1 BDC is finished but the state is false too (processing) How can i correct the state of tht session ?=
    thanks and regaards
    Andreas

    Good morning Rob,
    I've tried to release it but I get the following "false" message:
    Could not release folder "MIARMD_1029"  since it still contains a background job
    Message no. 00299
    -> there's no background job any longer!
    any ideas except creating new bdc-sessions???
    thx and greetings
    Andreas Mann

  • Updating a DB Table using ColdFusion(CFC)

    I need help BAD... please
    I have this app. most stuff works perfect. I just can seem to
    append the form fields to each row that gets checked in the
    Datagrid. I get errors with the dateField also. Can anyone help?
    This is my source:
    http://www.youngsmarket.com/youngsmarket/programs/national/nataccpro/bin/srcview/index.htm l
    This is the App in its current state. The form fileds update
    if a date is not selected. But I cant send the DataGrid or the date
    form fields:
    http://www.youngsmarket.com/youngsmarket/programs/national/nataccpro/bin/NatAccPro.cfm?Sup plierID=30
    My CFC that I want to UPDATE the table (I know need a loop or
    something) is like this:
    <cffunction name="addData" access="remote" output="false"
    hint="I insert data" returntype="void">
    <cfargument name="user" type="struct" required="true"
    />
    <CFQUERY DATASOURCE="NationalAccounts">
    INSERT INTO Programs
    (SupplierID, Supplier, DBA, ItemID, Item, StartDate, EndDate,
    ProgramType, Status, Priority, Descrip, FollowUp, TrackComp,
    PresLocal, TrackSales)
    values
    ('#Session.SupID#', '#Session.Sup#', '#user.DBA#',
    '#user.ItemID#', '#user.Item#', '#user.StartDate#',
    '#user.EndDate#', '#user.ProgramType#', '#user.Status#',
    '#user.Priority#', '#user.Descrip#', '#user.FollowUp#',
    '#user.TrackComp#', '#user.PresLocal#', '#user.TrackSales#')
    </CFQUERY>
    </cffunction>
    Thanks
    George

    Hi
    If at all you are using any DOWNLOAD and UPLOAD related function modules you can't run the BDC program in the background.
    If it is a Z table update you can create the table maintenance generator.
    other wise you can do it.
    You can run session in background.
    Reward points if useful
    Regards
    Anji

  • BDC SESSION METHOD EXPLAINED

    Hi,
    Eplained BDC Session Method
    flat file upload into sap

    ABAP BDC SESSION METHOD SAMPLE CODE
    pool of form routines
    include zmppn001.
    Define BDC Table Structure
    data: begin of itab_bdc_tab occurs 0.
    include structure bdcdata.
    data: end of itab_bdc_tab.
    Input record layout of Leagcy File
    data: begin of itab_xcel occurs 0,
    matnr(18) type c,
    werks(4) type c,
    alnag(2) type c,
    verid(4) type c,
    text1(40) type c,
    bstmi like mkal-bstmi,
    bstma like mkal-bstma,
    adatu(10) type c,
    bdatu(10) type c,
    stlal(2) type c,
    stlan(1) type c,
    serkz(1) type c,
    mdv01(8) type c,
    elpro(4) type c,
    alort(4) type c,
    end of itab_xcel.
    data: begin of lt_pp04_cache occurs 0,
    matnr like itab_xcel-matnr,
    werks like itab_xcel-werks,
    alnag like itab_xcel-alnag,
    plnnr like mapl-plnnr,
    arbpl like crhd-arbpl,
    ktext like crtx-ktext,
    end of lt_pp04_cache.
    data: v_ssnnr(4) type n,
    v_lines_in_xcel like sy-tabix,
    v_ssnname like apqi-groupid,
    v_trans_in_ssn type i,
    wa_xcel LIKE itab_xcel,
    l_tabix like sy-tabix,
    v_matnr like rc27m-matnr,
    v_plnnr like mapl-plnnr,
    v_plnal like mapl-plnal,
    v_tcode like sy-tcode value 'C223',
    v_plnty like plas-plnty value 'R',
    v_objty like crhd-objty value 'A',
    v_plpo_steus like plpo-steus value 'PP04',
    v_verwe like crhd-verwe value '0007'.
    Parameters
    selection-screen: skip 3.
    selection-screen: begin of block 1 with frame.
    parameters: p_name like rlgrap-filename
    default 'C:\My Documents\InputFile.txt'
    obligatory,
    bdc session name prefix
    p_bdcpfx(6) default 'ZPVCRT'
    obligatory,
    number for transction per BDC session
    p_trnssn type i
    default 2000 obligatory,
    retain the BDC session after successfull execution
    p_keep like apqi-qerase
    default 'X',
    user who will be executing BDC session
    p_uname like apqi-userid
    default sy-uname
    obligatory.
    selection-screen: end of block 1.
    possible entry list (F4 dropdown) for input file name
    at selection-screen on value-request for p_name.
    *-SELECT FILE FROM USERS LOCAL PC
    call function 'WS_FILENAME_GET'
    exporting
    DEF_FILENAME = ' '
    def_path = 'C:\Temp\'
    mask = ',.,..'
    mode = 'O'
    title = 'Select File '(007)
    importing
    filename = p_name
    RC =
    exceptions
    inv_winsys = 1
    no_batch = 2
    selection_cancel = 3
    selection_error = 4
    others = 5.
    if sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    begin the show
    start-of-selection.
    read data from input file
    perform transfer_xcel_to_itab.
    loop at itab_xcel.
    hang on to xcel line num
    l_tabix = sy-tabix.
    each line in the xcel file marks begining of new prod.version defn
    if num-of-trnas-in-session = 0, create new BDC session
    if v_trans_in_ssn is initial.
    perform bdc_session_open.
    endif.
    begin new bdc script for rtg create trans
    fill in bdc-data for prod.version maintenance screens
    perform bdc_build_script.
    insert the bdc script as a BDC transaction
    perform bdc_submit_transaction.
    keep track of how many BDC transactions were inserted in the BDC
    session
    add 1 to v_trans_in_ssn.
    if the user-specified num of trans in BDC session is reached OR
    if end of input file is reached, close the BDC session
    if v_trans_in_ssn = p_trnssn or
    l_tabix = v_lines_in_xcel.
    perform bdc_session_close.
    clear v_trans_in_ssn.
    endif.
    endloop.
    top-of-page.
    call function 'Z_HEADER'
    EXPORTING
    FLEX_TEXT1 =
    FLEX_TEXT2 =
    FLEX_TEXT3 =
    FORM TRANSFER_XCEL_TO_ITAB *
    Transfer Xcel Spreadsheet to SAP Internal Table *
    form transfer_xcel_to_itab.
    Read the tab-delimited file into itab
    call function 'WS_UPLOAD'
    exporting
    filename = p_name
    filetype = 'DAT'
    IMPORTING
    filelength = flength
    tables
    data_tab = itab_xcel
    exceptions
    conversion_error = 1
    file_open_error = 2
    file_read_error = 3
    invalid_table_width = 4
    invalid_type = 5
    no_batch = 6
    unknown_error = 7
    others = 8.
    if sy-subrc = 0.
    sort the data
    sort itab_xcel by matnr werks.
    clear v_lines_in_xcel.
    if no data in the file - error out
    describe table itab_xcel lines v_lines_in_xcel.
    if v_lines_in_xcel is initial.
    write: / 'No data in input file'.
    stop.
    endif.
    else.
    if file upload failed - error out
    write: / 'Error reading input file'.
    stop.
    endif.
    endform.
    FORM BDC_SESSION_OPEN *
    Open BDC Session *
    form bdc_session_open.
    create bdc session name = prefix-from-selectn-screen + nnnn
    add 1 to v_ssnnr.
    concatenate p_bdcpfx v_ssnnr into v_ssnname.
    open new bdc session
    call function 'BDC_OPEN_GROUP'
    exporting
    client = sy-mandt
    group = v_ssnname
    keep = p_keep
    user = p_uname
    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.
    endform.
    FORM BDC_BUILD_SCRIPT *
    Build BDC *
    form bdc_build_script.
    data: l_arbpl like crhd-arbpl,
    l_text1 like mkal-text1,
    l_mdv01 like mkal-mdv01,
    l_mapl like mapl.
    clear bdc-data itab - begin of new bdc transaction
    clear itab_bdc_tab.
    refresh itab_bdc_tab.
    read material cross reference tables to determine sap part#
    clear : v_matnr, v_plnnr, v_plnal.
    perform read_matnr_cross_ref using itab_xcel-matnr
    itab_xcel-werks
    changing v_matnr.
    determine the version description to use
    if itab_xcel-text1 is initial.
    l_text1 = itab_xcel-verid.
    else.
    l_text1 = itab_xcel-text1.
    endif.
    determine the routing group# and group ctr# to use
    perform read_routing .
    determine the production line to use
    if itab_xcel-mdv01 is initial.
    if not provided in the file then:
    prod line = work ctr on the last PP04 op of the rtg determined above
    perform read_wc_on_last_pp04 using v_plnnr v_plnal
    changing l_mdv01.
    NOTE: when executing the above form\routine, if v_plnnr is initial
    or v_plnal is initial, THEN l_mdv01 will automatically be
    returned blank (ie initial)
    else.
    l_mdv01 = itab_xcel-mdv01.
    endif.
    build bdc script
    perform bdc_build_script_record
    fill in initial screen
    using: 'X' 'SAPLCMFV' '1000',
    ' ' 'BDC_OKCODE' '=ENTE',
    ' ' 'MKAL-WERKS' itab_xcel-werks,
    ' ' 'MKAL-MATNR' v_matnr,
    ' ' 'MKAL_ADMIN-DISPO' space,
    ' ' 'MKAL-PLNNR' space,
    ' ' 'MKAL_ADMIN-STTAG' space,
    ' ' 'MKAL-PLNNG' space,
    ' ' 'MKAL-MDV01' space,
    ' ' 'MKAL-PLNNM' space,
    click create button on initial screen and go to detail screen
    'X' 'SAPLCMFV' '1000',
    ' ' 'BDC_OKCODE' '=CREA',
    fill in the detail screen and go back to initial screen
    'X' 'SAPLCMFV' '2000',
    ' ' 'BDC_OKCODE' '=CLOS',
    ' ' 'MKAL_EXPAND-MATNR' v_matnr,
    ' ' 'MKAL_EXPAND-VERID' itab_xcel-verid,
    ' ' 'MKAL_EXPAND-TEXT1' l_text1,
    ' ' 'MKAL_EXPAND-BSTMI' itab_xcel-bstmi,
    ' ' 'MKAL_EXPAND-BSTMA' itab_xcel-bstma,
    ' ' 'MKAL_EXPAND-ADATU' itab_xcel-adatu,
    ' ' 'MKAL_EXPAND-BDATU' itab_xcel-bdatu,
    ' ' 'MKAL_EXPAND-PLTYG' v_plnty,
    ' ' 'MKAL_EXPAND-PLNNG' v_plnnr,
    ' ' 'MKAL_EXPAND-ALNAG' v_plnal,
    ' ' 'MKAL_EXPAND-STLAL' itab_xcel-stlal,
    ' ' 'MKAL_EXPAND-STLAN' itab_xcel-stlan,
    ' ' 'MKAL_EXPAND-SERKZ' itab_xcel-serkz,
    ' ' 'MKAL_EXPAND-MDV01' l_mdv01,
    ' ' 'MKAL_EXPAND-ELPRO' itab_xcel-elpro,
    ' ' 'MKAL_EXPAND-ALORT' itab_xcel-alort,
    save the production version from initial screen
    'X' 'SAPLCMFV' '1000',
    ' ' 'BDC_OKCODE' '=SAVE'.
    endform.
    FORM BDC_SUBMIT_TRANSACTION *
    Submit BDC Session *
    form bdc_submit_transaction.
    Load BDC script as a trqansction in BDC session
    call function 'BDC_INSERT'
    exporting
    tcode = v_tcode
    tables
    dynprotab = itab_bdc_tab
    exceptions
    internal_error = 01
    not_open = 02
    queue_error = 03
    tcode_invalid = 04.
    endform.
    FORM BDC_BUILD_SCRIPT_RECORD *
    form bdc_build_script_record using dynbegin name value.
    clear itab_bdc_tab.
    if dynbegin = 'X'.
    move: name to itab_bdc_tab-program,
    value to itab_bdc_tab-dynpro,
    'X' to itab_bdc_tab-dynbegin.
    else.
    move: name to itab_bdc_tab-fnam,
    value to itab_bdc_tab-fval.
    shift itab_bdc_tab-fval left deleting leading space.
    endif.
    append itab_bdc_tab.
    endform.
    FORM BDC_SESSION_CLOSE *
    Close BDC Session *
    form bdc_session_close.
    close the session
    call function 'BDC_CLOSE_GROUP'
    exceptions
    not_open = 1
    queue_error = 2
    others = 3.
    skip 2.
    if sy-subrc ne 0.
    write: / 'Error Closing BDC Session ' , 'RETURN CODE: ', sy-subrc.
    else.
    write : / 'Session created:', v_ssnname,
    50 '# of transactions:', v_trans_in_ssn.
    endif.
    endform.
    *& Form read_routing_cache
    *FORM read_routing_cache USING pi_matnr
    pi_werks
    pi_alnag
    pi_verid
    pi_mdv01.
    DATA: BEGIN OF lt_plpo OCCURS 0,
    vornr LIKE plpo-vornr,
    objty LIKE crhd-objty,
    objid LIKE crhd-objid,
    arbpl LIKE crhd-arbpl,
    END OF lt_plpo,
    l_mapl_plnnr LIKE mapl-plnnr.
    determine the routing group#
    CLEAR lt_pp04_cache.
    chk if its in the cache first, if not then get it from MAPL table
    and put it in the cache
    READ TABLE lt_pp04_cache WITH KEY matnr = pi_matnr
    werks = pi_werks
    alnag = pi_alnag.
    IF sy-subrc = 0.
    do nothing - lt_pp04_cache header line has rtg#
    ELSE.
    get the routing group # from MAPL
    SELECT plnnr INTO l_mapl_plnnr
    FROM mapl UP TO 1 ROWS
    WHERE matnr = pi_matnr AND
    werks = pi_werks AND
    plnty = 'R' AND
    plnal = pi_alnag AND
    loekz = space.
    ENDSELECT.
    put it in the cache internal table
    IF NOT l_mapl_plnnr IS INITIAL.
    lt_pp04_cache-matnr = pi_matnr.
    lt_pp04_cache-werks = pi_werks.
    lt_pp04_cache-alnag = pi_alnag.
    lt_pp04_cache-plnnr = l_mapl_plnnr.
    APPEND lt_pp04_cache.
    ENDIF.
    ENDIF.
    if the rtg# was determined AND
    -- the work center was not determined yet AND
    -- work center was really needed for this line in the input file
    then
    -- read the work center from last PP04 operation on the routing
    -- update the cache accordingly
    IF NOT lt_pp04_cache-plnnr IS INITIAL AND
    lt_pp04_cache-arbpl IS INITIAL AND
    ( pi_verid IS INITIAL OR
    pi_mdv01 IS INITIAL ).
    read the last PP04 operation
    CLEAR lt_plpo.
    REFRESH lt_plpo.
    SELECT vornr eobjty eobjid e~arbpl
    INTO CORRESPONDING FIELDS OF TABLE lt_plpo
    FROM plas AS b
    INNER JOIN plpo AS c
    ON bplnty = cplnty AND
    bplnnr = cplnnr AND
    bzaehl = czaehl
    INNER JOIN crhd AS e
    ON carbid = eobjid
    WHERE b~plnty = v_plnty AND
    b~plnnr = lt_pp04_cache-plnnr AND
    b~plnal = lt_pp04_cache-alnag AND
    c~loekz = space AND
    c~steus = v_plpo_steus AND
    e~objty = v_objty AND
    e~werks = lt_pp04_cache-werks AND
    e~verwe = v_verwe.
    SORT lt_plpo BY vornr DESCENDING.
    READ TABLE lt_plpo INDEX 1.
    IF NOT lt_plpo-arbpl IS INITIAL.
    lt_pp04_cache-arbpl = lt_plpo-arbpl.
    read work center description
    SELECT SINGLE ktext INTO lt_pp04_cache-ktext
    FROM crtx WHERE objty = lt_plpo-objty AND
    objid = lt_plpo-objid AND
    spras = sy-langu.
    the following read will get the index of the correct record to be
    updated in the cache
    READ TABLE lt_pp04_cache
    WITH KEY matnr = pi_matnr
    werks = pi_werks
    alnag = pi_alnag.
    MODIFY lt_pp04_cache
    INDEX sy-tabix
    TRANSPORTING arbpl ktext.
    ENDIF.
    ENDIF.
    *ENDFORM. " read_last_pp04_operation_cache
    *& Form read_routing
    form read_routing.
    data: begin of lt_mapl occurs 0,
    plnnr like mapl-plnnr,
    plnal like mapl-plnal,
    end of lt_mapl,
    l_arbpl like crhd-arbpl.
    get all the rtg# and grp ctr# from MAPL
    select plnnr plnal
    into corresponding fields of table lt_mapl
    from mapl
    where matnr = v_matnr and
    werks = itab_xcel-werks and
    plnty = v_plnty and "Rate Routing
    loekz = space. "with del flag = OFF
    sort lt_mapl by plnal.
    if not itab_xcel-verid is initial.
    if the verid=0001 then use the 1st good rtg-grp# and grp-ctr#
    if itab_xcel-verid = '0001'.
    read table lt_mapl index 1.
    v_plnnr = lt_mapl-plnnr.
    v_plnal = lt_mapl-plnal.
    else.
    if the verid<>0001 then use the rtg-grp# and grp-ctr# of the routing
    whose work center on the last PP04 operation matches the given verid
    loop at lt_mapl.
    clear l_arbpl.
    get the work center from the last PP04 operation
    perform read_wc_on_last_pp04 using lt_mapl-plnnr
    lt_mapl-plnal
    changing l_arbpl.
    if itab_xcel-verid = l_arbpl.
    v_plnnr = lt_mapl-plnnr.
    v_plnal = lt_mapl-plnal.
    exit.
    endif.
    endloop.
    endif.
    else.
    do nothing
    endif.
    For version IDs that are other then '0000' or 'ZWIP' :--
    if itab_xcel-verid NE '0000' and
    itab_xcel-verid NE 'ZWIP'.
    if routing group# or group counter was not determined, make the
    valid-to date 99/99/9999 so that the BDC, on execution, errors out.
    if v_plnnr is initial or
    v_plnal is initial.
    itab_xcel-bdatu = '99/99/9999'.
    endif.
    endif.
    determine the routing group#
    CLEAR lt_pp04_cache.
    chk if its in the cache first, if not then get it from MAPL table
    and put it in the cache
    READ TABLE lt_pp04_cache WITH KEY matnr = pi_matnr
    werks = pi_werks
    alnag = pi_alnag.
    IF sy-subrc = 0.
    do nothing - lt_pp04_cache header line has rtg#
    ELSE.
    get the routing group # from MAPL
    put it in the cache internal table
    IF NOT l_mapl_plnnr IS INITIAL.
    lt_pp04_cache-matnr = pi_matnr.
    lt_pp04_cache-werks = pi_werks.
    lt_pp04_cache-alnag = pi_alnag.
    lt_pp04_cache-plnnr = l_mapl_plnnr.
    APPEND lt_pp04_cache.
    ENDIF.
    ENDIF.
    if the rtg# was determined AND
    -- the work center was not determined yet AND
    -- work center was really needed for this line in the input file
    then
    -- read the work center from last PP04 operation on the routing
    -- update the cache accordingly
    IF NOT lt_pp04_cache-plnnr IS INITIAL AND
    lt_pp04_cache-arbpl IS INITIAL AND
    ( pi_verid IS INITIAL OR
    pi_mdv01 IS INITIAL ).
    read the last PP04 operation
    CLEAR lt_plpo.
    REFRESH lt_plpo.
    SELECT vornr eobjty eobjid e~arbpl
    INTO CORRESPONDING FIELDS OF TABLE lt_plpo
    FROM plas AS b
    INNER JOIN plpo AS c
    ON bplnty = cplnty AND
    bplnnr = cplnnr AND
    bzaehl = czaehl
    INNER JOIN crhd AS e
    ON carbid = eobjid
    WHERE b~plnty = v_plnty AND
    b~plnnr = lt_pp04_cache-plnnr AND
    b~plnal = lt_pp04_cache-alnag AND
    c~loekz = space AND
    c~steus = v_plpo_steus AND
    e~objty = v_objty AND
    e~werks = lt_pp04_cache-werks AND
    e~verwe = v_verwe.
    SORT lt_plpo BY vornr DESCENDING.
    READ TABLE lt_plpo INDEX 1.
    IF NOT lt_plpo-arbpl IS INITIAL.
    lt_pp04_cache-arbpl = lt_plpo-arbpl.
    read work center description
    SELECT SINGLE ktext INTO lt_pp04_cache-ktext
    FROM crtx WHERE objty = lt_plpo-objty AND
    objid = lt_plpo-objid AND
    spras = sy-langu.
    the following read will get the index of the correct record to be
    updated in the cache
    READ TABLE lt_pp04_cache
    WITH KEY matnr = pi_matnr
    werks = pi_werks
    alnag = pi_alnag.
    MODIFY lt_pp04_cache
    INDEX sy-tabix
    TRANSPORTING arbpl ktext.
    ENDIF.
    ENDIF.
    endform. " read_last_pp04_operation_cache
    *& Form read_wc_on_last_pp04
    form read_wc_on_last_pp04 using pi_plnnr
    pi_plnal
    changing pe_arbpl.
    data: begin of lt_plpo occurs 0,
    vornr like plpo-vornr,
    objty like crhd-objty,
    objid like crhd-objid,
    arbpl like crhd-arbpl,
    end of lt_plpo.
    get all the PP04 operations for the given rtg# & grp-ctr#
    select vornr eobjty eobjid e~arbpl
    into corresponding fields of table lt_plpo
    from plas as b
    inner join plpo as c
    on bplnty = cplnty and
    bplnnr = cplnnr and
    bzaehl = czaehl
    inner join crhd as e
    on carbid = eobjid
    where b~plnty = v_plnty and "Rate Routing
    b~plnnr = pi_plnnr and
    b~plnal = pi_plnal and
    c~loekz = space and "Oper Del Flag = OFF
    c~steus = v_plpo_steus and "PP04
    e~objty = v_objty. "WC Obj Type = 'A'
    read the last operation
    sort lt_plpo by vornr descending.
    read table lt_plpo index 1.
    pe_arbpl = lt_plpo-arbpl.
    endform.
    Regards.

Maybe you are looking for

  • Showing pictures iphone 4 only portrait mode

    Hi, when I look at pictures in my Ipone 4 they only show up in portrait mode. It vill not work "turning the phone" showing the pictures in landscape. This goes as well for writing sms etc, only possible in portrait mode. ANy idea about the problem an

  • Print action's default printer

    Hi, I've configured a print action to trigger a custom smartform within CRMD_ORDER. My print action uses processing class CL_DOC_PROCESSING_CRM_ORDER, and method CRM_SRVORDER_EXEC_SMART_FORM When I execute the action, I get a printout that reads 'PDF

  • Material segregation in Prodn Order

    Hai, Can we do the Material Segregation to  Split the Production Order into three sections and create a new page for each section.  The three sections are based on how material is classified as1.High Value,2. Kitting,3. Packaging.. If anybody knows g

  • My secret questions, I answer but it says that it is not correct.  How can I change/fix this?  I don't remember what I put.

    I had my iPod die on me.  So I am reinstalling after getting another.  UIt asks for my secret questions.  I type what the answer was on one questions, and it says that is not correct.  No clue what I put.  How do I get past or change this? Help!

  • Chrome Browser - with NWBC, ScreenPersonas or BI

    Due to recent high-risk viruses and malware problems with IE - we are considering switching our default browser from IE to Chrome across the organization. Can anyone comment on risks/issues of ScreenPersonas, NWBC or BI with Chrome browser?