Capturing messages in session method

Hi All,
I am executing session using the program name rsbdcsub after executing the session mehtod I wanted to capture the messages at runtime.
Can anyone tell me how can I capture the messages at runtime.
This line is perticularly for Vinod Kumar who rejected my post as basic questions,
Vinod Kumar Please read the thread before rejecting.
Regards,
Sagar

Hi Vinod,
Thanks for reply and not rejecting my thread :).
I have already gone thorugh the link which u have send this is for only error message.
My requirement is something like
Capturing messages in BDC session
Please let me know if u have any solution for this.
Thanks again.
Sagar

Similar Messages

  • How to suppress status message in session method in a BDC?

    Hi experts,
                      I am upadting  condition records in VK12 by creating BDC sessions.I am getting a warning message which is stopping the processing.When I press Enter the processing continues but this is not replicated while processing the session.How can I avoid this.Please advice.
    Thanks and Regards
    Abhishek

    Hi Abhishek,
    find screen number where you are getting warning Message.
    In that screen either remove your cursor position or if it is not there then just put ok_code.
    so that whenever that screen will called, it will automatically skips.
    Regards,
    vijay

  • Error message log in session method of ALV report,

    In ALV report please let me know:
    1) In session method:
    where all error messages are stored,I know that error messages are stored in a log file, so please tell me where is it stored.
    2)transaction method:
    How to handle error messages in transaction methos(for eg if a weight field text box value is negative)

    Ans for 2nd point.
    CALL TRANSACTION c_mb USING i_bdcdata
                              MODE g_ctumode
                              UPDATE g_cupdate
                              MESSAGES INTO i_messtab.
       COMMIT WORK.
       IF sy-subrc EQ 0. " BDC Executed Successfully
         CLEAR wa_messtab.
         LOOP AT i_messtab INTO wa_messtab .
           IF wa_messtab-msgtyp  = 'S' AND
              wa_messtab-msgid   = 'M7' AND
              wa_messtab-msgnr   = '060'.
             CALL FUNCTION 'MESSAGE_TEXT_BUILD'
               EXPORTING
                 msgid               = wa_messtab-msgid
                 msgnr               = wa_messtab-msgnr
                 msgv1               = wa_messtab-msgv1
                 msgv2               = wa_messtab-msgv2
                 msgv3               = wa_messtab-msgv3
                 msgv4               = wa_messtab-msgv4
               IMPORTING
                 message_text_output = l_msg.
             APPEND l_msg TO i_sucsess.
             CLEAR l_msg.
             g_docsuc = 1.
           ELSE.
             IF wa_messtab-msgtyp  = 'E'.
               CALL FUNCTION 'MESSAGE_TEXT_BUILD'
                 EXPORTING
                   msgid               = wa_messtab-msgid
                   msgnr               = wa_messtab-msgnr
                   msgv1               = wa_messtab-msgv1
                   msgv2               = wa_messtab-msgv2
                   msgv3               = wa_messtab-msgv3
                   msgv4               = wa_messtab-msgv4
                 IMPORTING
                   message_text_output = l_msg.
               g_errflg = 1.
               APPEND l_msg TO i_error.
               CLEAR: l_msg.
             ENDIF.

  • What is the diffreence between call transaction and session method

    hi gurus
    can any one suggest me
    what is the difference between call transaction and session methods
    in which cases we have to use teh call transaction and
    in which cases we have to use session method.
    thank you
    regards
    kals.

    CLASSICAL BATCH INPUT (Session Method)
    CALL TRANSACTION
    BATCH INPUT METHOD:
    This method is also called as ‘CLASSICAL METHOD’.
    Features:
    Asynchronous processing.
    Synchronous Processing in database update.
    Transfer data for more than one transaction.
    Batch input processing log will be generated.
    During processing, no transaction is started until the previous transaction has been written to the database.
    CALL TRANSACTION METHOD :
    This is another method to transfer data from the legacy system.
    Features:
    Synchronous processing. The system performs a database commit immediately before and after the CALL TRANSACTION USING statement.
    Updating the database can be either synchronous or asynchronous. The program specifies the update type.
    Transfer data for a single transaction.
    Transfers data for a sequence of dialog screens.
    No batch input processing log is generated.
    http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
    Among the two methods call transaction is better compared to session bcoz data transfer is faster in it.
    Differences between call transaction and session.
    Session Method:
    1) Data is not updated in the database table until the session is processed.
    2) No sy-subrc is returned.
    3) Error log is created for error records.
    4) Updation is always synchronous.
    Call Transaction Method:
    1) Immediate updation in the database table.
    2) sy-subrc is returned.
    3)Error need to be handled explicitly.
    4) updation can be synchronous as well as asynchronous.
    2) ya u can use using the N mode no screen.
    3)u can't handle multiple transaction in call transaction.
    4) u can handle multiple transaction in session using the BDC_INSERT fm.
    5)When u go to SM35 u can able to see the error records.
    Which is best?
    That depends on your requirement. Both of them have there advantages.
    According to the situation u can choose any one of these.
    difference between batch input and call transaction in BDC Session method.
    1) synchronous processing.
    2) can tranfer large amount of data.
    3) processing is slower.
    4) error log is created
    5) data is not updated until session is processed.
    Call transaction.
    1) asynchronous processing
    2) can transfer small amount of data
    3) processing is faster.
    4) errors need to be handled explicitly
    5) data is updated automatically
    For session method,these are the function modules to b used.
    BDC_OPEN_GROUP
    BDC_INSERT
    BDC_CLOSE_GROUP
    For call transaction,this is the syntax.
    CALL TRANSACTION TCODE USING BDCDATA
    MODE A or E or N
    UPDATE A or S
    MESSAGES INTO MESSTAB.
    Take a scenario where we need to post documents in FB01 and the input file has say 2000 records (2000 documents, not line items in FB01 but 2000 records)
    In the BDC call transaction method
    We call the transaction FB01 2000 times (once for each record posting) and if the processing fails in record no 3 it can be captured and start with reocord 4.
    Eg: Loop at itab.
    call transaction FB01
    capture errors
    endloop.
    In the session method.
    We do not explicity call the transaction 2000 times, but all the records are appeneded into a session and this session is stored. The processinf of the session is done wwhenever the user wants it to be done. Hence the errors cannot be captured in the program itself
    Check these link:
    http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
    http://www.sap-img.com/abap/question-about-bdc-program.htm
    http://www.itcserver.com/blog/2006/06/30/batch-input-vs-call-transaction/
    http://www.planetsap.com/bdc_main_page.htm
    Batch Input Session method is asynchronous as told by others here. But the advantage of this is that you have all the error messages and the data for each transaction held persistantly. You don't have to code anything for processing them or writing the logs.
    But at the same time, the same feature can be disadvantageous if you need to react to an error or if there are too many errors to manually correct in a session. Since the session are created in the program and its execution is done seperately, you loose the trackability of such transactions.
    With a call transaction, what was a disadvantage above will become an advantage. Call transaction immediately gives you messages back and you can react to it in your program. But the disadvantage is that, if you have several hundreds of transactions to run, running them from within the program can be resource crunching affair. It will hamper the system performance and you cannot really distribute the load. Of course, you have some mechanisms with which you can overcome this, but you will have to code for it. Also, storing the messages and storing the errored transaction data etc will have to be handled by you in the program. Whereas, in batch input session, your program's job is to just create the session, after that everything is standard SAP system's responsibility.
    Ideally, you should do a call transaction if the resources are not a problem and if it fails, put the errored transaction into a session.
    You can decide based on the data volume that your BDC is processing. If data volume is high go for session else call transaction will do.The call transaction updates will be instantaneous where as session needs to be processed explictly after creation.
    Session Method
    1) Session method supports both small amount of data aswell as large amount of data
    2) data processing is asynchronus and data updation is synchronus.
    3) it process multiple apllication while perfomaning validations.
    4) in session method data will be updated in data base only after processing session only.
    5) system provide by default logfile for handling error records.
    6) it supports both foreground aswell as background process
    in bdc we use FM ...
    bdc_open_group " for creating Session
    bdc_insert " adding transaction and bdcdata table for updating database
    bdc_close_group " for closing Session
    Call Transaction
    1) Call transaction exclusively for small amout of data
    2) it supports only one apllication while perfoming validations
    3) there is no default logfile, We can explicitly provide logic for creating logfile for handling error records.
    we can create logfile by using structure....BDCMSGCOLL
    4) it doesn't support background processing.
    5) data processing is synchronous and Data updation is Synchronous( default), in
    this method also supports daya updation in asynchronus process also.
    syntax:
    Call transaction <transaction-name> using BDCDATA
    mode <A/N/E>
    update <L/A/S>
    messages into BDCMSGCOLL.
    BDC:
    Batch Data Communication (BDC) is the process of transferring data from one SAP System to another SAP system or from a non-SAP system to SAP System.
    Features :
    BDC is an automatic procedure.
    This method is used to transfer large amount of data that is available in electronic medium.
    BDC can be used primarily when installing the SAP system and when transferring data from a legacy system (external system).
    BDC uses normal transaction codes to transfer data.
    Types of BDC :
    CLASSICAL BATCH INPUT (Session Method)
    CALL TRANSACTION
    BATCH INPUT METHOD:
    This method is also called as &#8216;CLASSICAL METHOD&#8217;.
    Features:
    Asynchronous processing.
    Synchronous Processing in database update.
    Transfer data for more than one transaction.
    Batch input processing log will be generated.
    During processing, no transaction is started until the previous transaction has been written to the database.
    CALL TRANSACTION METHOD :
    This is another method to transfer data from the legacy system.
    Features:
    Synchronous processing. The system performs a database commit immediately before and after the CALL TRANSACTION USING statement.
    Updating the database can be either synchronous or asynchronous. The program specifies the update type.
    Transfer data for a single transaction.
    Transfers data for a sequence of dialog screens.
    No batch input processing log is generated.
    For BDC:
    http://myweb.dal.ca/hchinni/sap/bdc_home.htm
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/bdc&
    http://www.sap-img.com/abap/learning-bdc-programming.htm
    http://www.sapdevelopment.co.uk/bdc/bdchome.htm
    http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
    http://help.sap.com/saphelp_47x200/helpdata/en/69/c250684ba111d189750000e8322d00/frameset.htm
    http://www.sapbrain.com/TUTORIALS/TECHNICAL/BDC_tutorial.html
    Check these link:
    http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
    http://www.sap-img.com/abap/question-about-bdc-program.htm
    http://www.itcserver.com/blog/2006/06/30/batch-input-vs-call-transaction/
    http://www.planetsap.com/bdc_main_page.htm
    call Transaction or session method ?
    Check the following links:
    http://www.sap-img.com/bdc.htm
    See below example code :
    Call three FM : BDC_OPEN_GROUP,BDC_INSERT and BDC_CLOSE_GROUP.
    Once you execute the program and it creates the session at SM35 Transaction.
    Report : ZMPPC011
    Type : Data upload
    Author : Chetan Shah
    Date : 05/05/2005
    Transport : DV3K919557
    Transaction: ??
    Description: This ABAP/4 Program creates new Production Versions
    (C223). It accepts tab-delimited spreadsheet input and
    creates BDC sessions.
    Modification Log
    Date Programmer Request # Description
    06/10/2005 Chetan Shah DV3K919557 Initial coding
    report zmppc011 no standard page heading line-size 120 line-count 55
    message-id zz.
    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 verid0001 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. " read_wc_on_last_pp04
    Goto LSMW-> Select Direct Input method in 1st step. These are the standard programs for data transfer.
    Otherwise goto SPRO->SAP Reference IMG-> Under this you'll find standard data transfer programs module wise.
    Regards,
    Sunil Kumar Mutyala

  • While uploading data into the r/3 using call transaction or session method

    hi experts
    while uploading data into the r/3 using call transaction or session method error occured in the middle of the processing then how these methods behaves it transfers next records or not?

    hai
    Session method: The records are not added to the database until the session is processed. sy-subrc is not returned. Error logs are created for error records. Updation in database table is always Synchronous.
    Call Transaction method: The records are immediately added to the database table. sy-subrc is returned to 0 if successful. Error logs are not created and hence the errors need to be handled explicitly. Updation in database table is either Synchronous or Asynchronous.
    While to transfer the data from the through if any errors occurs until the errors are the complete the data is not transfer to the SAP system.
    the system compulsory shows the errors. that errors are stored into the error logs (Transaction is SM35).
    so the session method should not return any value.
    In call transaction method data is directly pass to the SAP system.
    So its compulsory return the value.
    Because of the call transaction is the function.
    A function should return the value mandatory
    In session method errors stroed in SYSTEM GENRATED ERROR LOG.
    IN CALL TRANSACTION TO CAPTURE THE ERRORS WE SHOULD PERFORM THE FOLLOWING.
    FIRST ME MUST DECLARE AN INTERNAL TABLE WITH THE STRUCTURE OF BDCMSGCOLL TABLE.
    THEN WHILE WRITING THE CALL TRANSACTION STATEMENT WE SHOULD PUT THE 'E' MODE FOR CAPTURING ALL THE ERRORS.
    THEN FINALLY THE CAPTURED ERRORS MUST TO SENT TO THE INTERNAL TABLE WHICH WE DECLARED IN THE BEGINNING WITH BDCMSGCOLL BY USING THE FUNCTION MODULE "FORMAT_MESSAGE"
    AND THUS THE ERROR MESSAGES WILL BE SENT TO THE INTERNAL TABLE WHICH WE DECLARED AT THE BEGINNING.

  • Difference between Session method and call transaction

    Hi,
    please give me the differences between session method and call transaction,
    briefly explaining synchronus , asynchronus, process, update.
    Thanks in advance

    Hi Vijay Kumar
    CLASSICAL BATCH INPUT (Session Method)
    CALL TRANSACTION
    BATCH INPUT METHOD:
    This method is also called as ‘CLASSICAL METHOD’.
    Features:
    Asynchronous processing.
    Synchronous Processing in database update.
    Transfer data for more than one transaction.
    Batch input processing log will be generated.
    During processing, no transaction is started until the previous transaction has been written to the database.
    CALL TRANSACTION METHOD :
    This is another method to transfer data from the legacy system.
    Features:
    Synchronous processing. The system performs a database commit immediately before and after the CALL TRANSACTION USING statement.
    Updating the database can be either synchronous or asynchronous. The program specifies the update type.
    Transfer data for a single transaction.
    Transfers data for a sequence of dialog screens.
    No batch input processing log is generated.
    http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
    Among the two methods call transaction is better compared to session bcoz data transfer is faster in it.
    Differences between call transaction and session.
    Session Method:
    1) Data is not updated in the database table until the session is processed.
    2) No sy-subrc is returned.
    3) Error log is created for error records.
    4) Updation is always synchronous.
    Call Transaction Method:
    1) Immediate updation in the database table.
    2) sy-subrc is returned.
    3)Error need to be handled explicitly.
    4) updation can be synchronous as well as asynchronous.
    2) ya u can use using the N mode no screen.
    3)u can't handle multiple transaction in call transaction.
    4) u can handle multiple transaction in session using the BDC_INSERT fm.
    5)When u go to SM35 u can able to see the error records.
    Which is best?
    That depends on your requirement. Both of them have there advantages.
    According to the situation u can choose any one of these.
    difference between batch input and call transaction in BDC Session method.
    1) synchronous processing.
    2) can tranfer large amount of data.
    3) processing is slower.
    4) error log is created
    5) data is not updated until session is processed.
    Call transaction.
    1) asynchronous processing
    2) can transfer small amount of data
    3) processing is faster.
    4) errors need to be handled explicitly
    5) data is updated automatically
    For session method,these are the function modules to b used.
    BDC_OPEN_GROUP
    BDC_INSERT
    BDC_CLOSE_GROUP
    For call transaction,this is the syntax.
    CALL TRANSACTION TCODE USING BDCDATA
    MODE A or E or N
    UPDATE A or S
    MESSAGES INTO MESSTAB.
    Take a scenario where we need to post documents in FB01 and the input file has say 2000 records (2000 documents, not line items in FB01 but 2000 records)
    In the BDC call transaction method
    We call the transaction FB01 2000 times (once for each record posting) and if the processing fails in record no 3 it can be captured and start with reocord 4.
    Eg: Loop at itab.
    call transaction FB01
    capture errors
    endloop.
    In the session method.
    We do not explicity call the transaction 2000 times, but all the records are appeneded into a session and this session is stored. The processinf of the session is done wwhenever the user wants it to be done. Hence the errors cannot be captured in the program itself
    Check these link:
    http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
    http://www.sap-img.com/abap/question-about-bdc-program.htm
    http://www.itcserver.com/blog/2006/06/30/batch-input-vs-call-transaction/
    http://www.planetsap.com/bdc_main_page.htm
    Batch Input Session method is asynchronous as told by others here. But the advantage of this is that you have all the error messages and the data for each transaction held persistantly. You don't have to code anything for processing them or writing the logs.
    But at the same time, the same feature can be disadvantageous if you need to react to an error or if there are too many errors to manually correct in a session. Since the session are created in the program and its execution is done seperately, you loose the trackability of such transactions.
    With a call transaction, what was a disadvantage above will become an advantage. Call transaction immediately gives you messages back and you can react to it in your program. But the disadvantage is that, if you have several hundreds of transactions to run, running them from within the program can be resource crunching affair. It will hamper the system performance and you cannot really distribute the load. Of course, you have some mechanisms with which you can overcome this, but you will have to code for it. Also, storing the messages and storing the errored transaction data etc will have to be handled by you in the program. Whereas, in batch input session, your program's job is to just create the session, after that everything is standard SAP system's responsibility.
    Ideally, you should do a call transaction if the resources are not a problem and if it fails, put the errored transaction into a session.
    You can decide based on the data volume that your BDC is processing. If data volume is high go for session else call transaction will do.The call transaction updates will be instantaneous where as session needs to be processed explictly after creation.
    Session Method
    1) Session method supports both small amount of data aswell as large amount of data
    2) data processing is asynchronus and data updation is synchronus.
    3) it process multiple apllication while perfomaning validations.
    4) in session method data will be updated in data base only after processing session only.
    5) system provide by default logfile for handling error records.
    6) it supports both foreground aswell as background process
    in bdc we use FM ...
    bdc_open_group " for creating Session
    bdc_insert " adding transaction and bdcdata table for updating database
    bdc_close_group " for closing Session
    Call Transaction
    1) Call transaction exclusively for small amout of data
    2) it supports only one apllication while perfoming validations
    3) there is no default logfile, We can explicitly provide logic for creating logfile for handling error records.
    we can create logfile by using structure....BDCMSGCOLL
    4) it doesn't support background processing.
    5) data processing is synchronous and Data updation is Synchronous( default), in
    this method also supports daya updation in asynchronus process also.
    syntax:
    Call transaction <transaction-name> using BDCDATA
    mode <A/N/E>
    update <L/A/S>
    messages into BDCMSGCOLL.
    BDC:
    Batch Data Communication (BDC) is the process of transferring data from one SAP System to another SAP system or from a non-SAP system to SAP System.
    Features :
    BDC is an automatic procedure.
    This method is used to transfer large amount of data that is available in electronic medium.
    BDC can be used primarily when installing the SAP system and when transferring data from a legacy system (external system).
    BDC uses normal transaction codes to transfer data.
    Types of BDC :
    CLASSICAL BATCH INPUT (Session Method)
    CALL TRANSACTION
    BATCH INPUT METHOD:
    This method is also called as ‘CLASSICAL METHOD’.
    Features:
    Asynchronous processing.
    Synchronous Processing in database update.
    Transfer data for more than one transaction.
    Batch input processing log will be generated.
    During processing, no transaction is started until the previous transaction has been written to the database.
    CALL TRANSACTION METHOD :
    This is another method to transfer data from the legacy system.
    Features:
    Synchronous processing. The system performs a database commit immediately before and after the CALL TRANSACTION USING statement.
    Updating the database can be either synchronous or asynchronous. The program specifies the update type.
    Transfer data for a single transaction.
    Transfers data for a sequence of dialog screens.
    No batch input processing log is generated.
    For BDC:
    http://myweb.dal.ca/hchinni/sap/bdc_home.htm
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/bdc&
    http://www.sap-img.com/abap/learning-bdc-programming.htm
    http://www.sapdevelopment.co.uk/bdc/bdchome.htm
    http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
    http://help.sap.com/saphelp_47x200/helpdata/en/69/c250684ba111d189750000e8322d00/frameset.htm
    http://www.sapbrain.com/TUTORIALS/TECHNICAL/BDC_tutorial.html
    Check these link:
    http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
    http://www.sap-img.com/abap/question-about-bdc-program.htm
    http://www.itcserver.com/blog/2006/06/30/batch-input-vs-call-transaction/
    http://www.planetsap.com/bdc_main_page.htm
    call Transaction or session method ?
    Check the following links:
    http://www.sap-img.com/bdc.htm
    See below example code :
    Call three FM : BDC_OPEN_GROUP,BDC_INSERT and BDC_CLOSE_GROUP.
    Once you execute the program and it creates the session at SM35 Transaction.
    Report : ZMPPC011
    Type : Data upload
    Author : Chetan Shah
    Date : 05/05/2005
    Transport : DV3K919557
    Transaction: ??
    Description: This ABAP/4 Program creates new Production Versions
    (C223). It accepts tab-delimited spreadsheet input and
    creates BDC sessions.
    Modification Log
    Date Programmer Request # Description
    06/10/2005 Chetan Shah DV3K919557 Initial coding
    report zmppc011 no standard page heading line-size 120 line-count 55
    message-id zz.
    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 verid0001 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. " read_wc_on_last_pp04
    Goto LSMW-> Select Direct Input method in 1st step. These are the standard programs for data transfer.
    Otherwise goto SPRO->SAP Reference IMG-> Under this you'll find standard data transfer programs module wise.
    Reward points,
    Shakir

  • Session method and call transaction methos which one is the sap recomonded

    hi
    PLease give me the answer to these questions.
    session method and call transaction methos which one is the sap recomonded why .
    2) if we want to maintain BDC program in all the systems.wt to d0

    Hi Revethi,
    Here is the difference between the Session and Call Transaction method.
         Session
    Session method supports both small amount of data aswell as large amount of data
    2) data processing is asynchronus and data updation is synchronus.
    3) it process multiple apllication while perfomaning validations.
    4) in session method data will be updated in data base only after processing session only.
    5) system provide by default logfile for handling error records.
    6) it supports both foreground aswell as background process
    in bdc we use FM ... bdc_open_group " for creating Session
    bdc_insert " adding transaction and bdcdata table for updating database
    bdc_close_group " for closing Session
          Call Transaction
    Call transaction exclusively for small amout of data
    2) it supports only one apllication while perfoming validations
    3) there is no default logfile, We can explicitly provide logic for creating logfile for handling error records.
    we can create logfile by using structure....BDCMSGCOLL
    4) it doesn't support background processing.
    5) data processing is synchronous and Data updation is Synchronous( default), in
    this method also supports daya updation in asynchronus process also.
    Syntax:
    Call transaction <transaction-name> using BDCDATA
    mode <A/N/E> update <L/A/S>
    messages into BDCMSGCOLL.

  • Error in my BDC SESSION METHOD

    Hi,
    I was trying work on BDC SESSION METHOD AND MY TCODE IS XK01.
    Here is my code can some one tell me where i am doing wrong becoz its not giving the output as I expected. And I am uploading a tab delimeter file.
    report ZAN_BDCVENDOR
           no standard page heading line-size 255.
    include bdcrecx1.
    DATA: I_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF RECORD OCCURS 0,
    LIFNR(016),
    BURKS(004),
    EKORG(004),
    KTOKK(004),
    AKONT(010),
    FDGRV(010),
    WAERS(005),
    END OF RECORD.
    start-of-selection.
    perform open_group.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                      = 'C:\VENDOR.TXT'
    FILETYPE                      = 'ASC'
      tables
        data_tab                      = RECORD
    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.
    perform bdc_dynpro      using 'SAPMF02K' '0100'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'USE_ZAV'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'RF02K-LIFNR'
                                  '8765'.
    perform bdc_field       using 'RF02K-BUKRS'
                                  '1000'.
    perform bdc_field       using 'RF02K-EKORG'
                                  '1000'.
    perform bdc_field       using 'RF02K-KTOKK'
                                  '0001'.
    perform bdc_field       using 'USE_ZAV'
                                  'X'.
    perform bdc_dynpro      using 'SAPMF02K' '0210'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFB1-FDGRV'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=UPDA'.
    perform bdc_field       using 'LFB1-AKONT'
                                  '160000'.
    perform bdc_field       using 'LFB1-FDGRV'
                                  'A1'.
    perform bdc_dynpro      using 'SAPMF02K' '0310'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFM1-WAERS'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=UPDA'.
    perform bdc_field       using 'LFM1-WAERS'
                                  'usd'.
    perform bdc_transaction using 'XK01'.
    ENDLOOP.
    perform close_group.
                  CALL FUNCTION 'BDC_OPEN_GROUP'
                   EXPORTING
                    CLIENT                    = SY-MANDT
                    DEST                      = FILLER8
                     GROUP                     = 'SESSION1'
                    HOLDDATE                  = FILLER8
                    KEEP                      = FILLER1
                     USER                      = SY-UNAME
                    RECORD                    = FILLER1
                    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 'ERROR IN OPEN_GROUP'.
                  ENDIF.
                   CALL FUNCTION 'BDC_INSERT'
                   EXPORTING
                     TCODE                  = TCODE
                     POST_LOCAL             = NOVBLOCAL
                     PRINTING               = NOPRINT
                     SIMUBATCH              = ' '
                     CTUPARAMS              = ' '
                     TABLES
                       dynprotab              = I_BDCDATA
                   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.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
                   ENDIF.
                   CALL FUNCTION 'BDC_CLOSE_GROUP'
                   EXCEPTIONS
                     NOT_OPEN          = 1
                     QUEUE_ERROR       = 2
                     OTHERS            = 3
                   IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
                   ENDIF.
    I appreciate

    Hi,
    i guess, the error is due to, u didnt pass the TCODE parameter in BDC_INSERT FM.
    Try by passing it...
    CALL FUNCTION 'BDC_INSERT'
    EXPORTING
    TCODE = TCODE*
    POST_LOCAL = NOVBLOCAL
    PRINTING = NOPRINT
    SIMUBATCH = ' '
    CTUPARAMS = ' '
    TABLES
    dynprotab = I_BDCDATA
    EXCEPTIONS
    INTERNAL_ERROR = 1
    NOT_OPEN = 2
    QUEUE_ERROR = 3
    TCODE_INVALID = 4
    PRINTING_INVALID = 5
    POSTING_INVALID = 6
    OTHERS = 7
    Hope it works!!
    Regards,
    Pavan

  • Regarding PO creating with condition record Using Session method

    Hi All,
    I am facing the following problem during po creation using BDC session method.
       If there is error in any of the record in the PO upload file and if we jump to next record during batch input session, system changes data of previous correct record.
    Example u2013 Consider following data
    Matl code     Matl Description     Qty     UoM     Price
    98652565     Floater08 EPS Insert -with sta     15000     EA     171
    60890125     INSERT (PACKAGING) Wellpappe T     14000     EA     52.3
    65646353     INSERT CASE PACKAGING, univers     10000     EA     56.9
    98725563     Shipper-2nd-NA-Bubble TS.1850     9000     EA     213.4
    Consider that record 2 (60890125) contain wrong data. If we skip this record and move to next record 65646353, system executes previous correct record (98652565) and changes net price of that record (here its 171) to 56.9. If record 3 is also wrong, it will capture price from record 4 and will put it for record 1.
    If anyone know the solution, Please let me know.
    Thanks in Advance.

    Hi Prasad,
    You may not be clearing some workarea in the program while looping or while sending data to screens, clear workareas when required.
    If you still face the same issue, try posting the code here, lets see, whats the problem is.
    Rgds,
    Sripal

  • Creating Sales order texts while using BDC session method is not working

    Hi All,
    I have an existing program which creates sales order using BDC session method.( Actual program uses BAPI to create sales order and in case if any error occurs during creation of sales order BDC session is generated so that user can process it later and i am facing issues in this part of code where it uses BDC)
    I wanted to modify this BDC sesion  to update the sales order text also. I tried recording VA01 for creationg sales order text unfortunatly it is not capturing the data i am entering in the text fields.
    Please suggest if there is any way to create sales order using BDC.
    Regards
    Sheeba

    Hi Madhu,
    '=TP_CREATE' is the OK code i am getting for creating TEXTS. But the text entered are not captured in BDC.
    Part of BDC program generated for cretaing sales order texts.
    perform bdc_dynpro      using 'SAPMV45A' '4003'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=%_GC 128 22'.
    perform bdc_field       using 'LV70T-SPRAS'
                                  'EN'.
    perform bdc_dynpro      using 'SAPMV45A' '4003'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=TP_CREATE'.
    perform bdc_field       using 'LV70T-SPRAS'
                                  'EN'.
    perform bdc_dynpro      using 'SAPMV45A' '4003'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=%_GC 128 22'.
    perform bdc_field       using 'LV70T-SPRAS'
                                  'EN'.
    perform bdc_dynpro      using 'SAPMV45A' '4003'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=TP_CREATE'.
    perform bdc_field       using 'LV70T-SPRAS'
                                  'EN'.
    perform bdc_dynpro      using 'SAPMV45A' '4003'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/EBACK'.
    perform bdc_field       using 'LV70T-SPRAS'
                                  'EN'.
    perform bdc_dynpro      using 'SAPMV45A' '4001'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=SICH'.
    Regards,
    Sheeba

  • Issue in session method --- urgent

    Hi,
    I developed one bdc which is working fine in call transaction mode when i am trying to run in session method it is giving information message like '    Processing of batch input session completed'.
    i am sending my code below.
    report ZAAATEST
           no standard page heading line-size 255.
    DATA: wa_opt TYPE ctu_params.
    PARAMETERS : P_GROUP LIKE APQI-GROUPID DEFAULT 'AVANTIMRG10'.
    wa_opt-nobinpt = 'X'.
    wa_opt-DISMODE = 'A'.
    wa_opt-UPDMODE = 'L'.
    WA_OPT-RACOMMIT = 'X'.
    include bdcrecx1.

    Hi,
    Go to SM35 transaction code.
    Click on your session name.
    And click on process.
    Regards,
    Bhanu

  • Session method

    hi all,
           i wrote the session method for f-02 transaction,
    if voucher number(bkpf-xblnr) found in bkpf i need to skip that voucher number.i need to display error report like (xblnr belnr bldat). and any errors experienced during batch input creation like format errors etc.these errors also i need to disply in error report.
    if voucher number(bkpf-xblnr) not found in bkpf i need to insert that voucher number.
    if in the flat file 2 records found in bkpf and 2 records not found in bkpf. in sm35 log file it must show 2 records processed and
    2 reocrds with errors.
    *& Report  ZFGLDIOO20                                                    *
    PROGRAM NAME   : ZFGLDI0020
    REQUEST NO     : CD1K900572
    APLICATION AREA: FI
    AUTHOR         : SRINIVAS M
    DATE           : 13-07-2006
    DESCRIPTION    :This interface will Developement of a Program to read
    and Upload the electronic file containig billing refunds information.
    *This upload file will generate transactions in the Accounts payble module.
    *After the payments have been done an out put file is created containing the cheque
    *information to be uploaded on the revenue billing databases.
    REPORT HEADER                                                        *
    REPORT zfgldi0020  NO STANDARD PAGE HEADING
                       LINE-SIZE 255
                       LINE-COUNT 65.
    ====[TABLES]======================================================
    TABLES: bkpf,   "Accounting Document Header"
            bseg,   "Accounting Document Segment"
            bsec.   "One-Time Account Data Document Segment"
    ====[TYPE-POOLS]======================================================
    TYPE-POOLS: slis.
    ===[INTERNAL TABLES]==================================================
    DATA : BEGIN OF it_file_up OCCURS 0,
             sgtxt(11),
             ls_c2(5),
             zuonr(21),
             name1(51),
             ls_c5(7),
             ls_c6(2),
             ls_c7(5),
             ls_c8(4),
             bldat(9),
             ls_c10(9),
             ls_c11(21),
             ls_c12(2),
             ls_c13(31),
             ls_c14(31),
             ls_c15(31),
             ls_c16(31),
             ls_c17(31),
             ls_c18(5),
             wrbtr(16),
             ls_c20(51),
             ls_c21(51),
             ls_c22(51),
             ls_c23(51),
             ls_c24(51),
             ls_c25(7),
             ls_c26(21),
             ls_c27(3),
             ls_c28(21),
             ls_c29(9),
             ls_c30(21),
             ls_c31(16),
           END OF it_file_up.
    DATA : BEGIN OF it_file OCCURS 0,
             bldat(10),                                   "Document Date"
             blart(2) TYPE c VALUE 'ZD',                  "Document Type"
             bukrs(4) TYPE n VALUE '0100',                "Company Code"
             budat(10),                                    "Posting Date"
             monat(2) TYPE n VALUE '1',                    " Period"
             waers(3) TYPE c VALUE 'ZAR',                  "Currency"
             xblnr(16) TYPE c,  " VALUE 'VOUCHER NUMBER',    " Reference"
             bktxt(25) TYPE c VALUE 'BILLING REFUNDS',    "Doc headertext"
             bschl(2) TYPE c VALUE '31',                  "Posting Key"
             hkont(7) TYPE n VALUE '490905',               "Account"
             name1(35) TYPE c,                            "Name"
             stras(35) TYPE c VALUE '66 Jorissen street', "Street"
             ort01(35) TYPE c VALUE 'JOHANNESBERG',       "City"
             pstlz(4) TYPE n VALUE '2001',                "Postal Code"
             wrbtr(16) ,                                  "Amount"
             mwskz(2) TYPE c VALUE 'V0',                  "Tax Code"
             zuonr(18) TYPE c,                            "Assignment"
             sgtxt(50) TYPE c,                            "Text"
             bschl1(2) TYPE c VALUE '40',                 "Posting Key"
             hkont1(7) TYPE n VALUE '8701120',            "Account"
             wrbtr1(16),                                  "Amount"
             zuonr1(18) TYPE c,                           "Assignment"
             sgtxt1(50) TYPE c,                            "Text"
           END OF it_file.
    DATA : BEGIN OF it_process OCCURS 0,
             bldat(10),                                   "Document Date"
             blart(2) TYPE c VALUE 'ZD',                  "Document Type"
             bukrs(4) TYPE n VALUE '0100',                "Company Code"
             budat(10),                                    "Posting Date"
             monat(2) TYPE n VALUE '1',                    " Period"
             waers(3) TYPE c VALUE 'ZAR',                  "Currency"
             xblnr(16) TYPE c,  " VALUE 'VOUCHER NUMBER',    " Reference"
             bktxt(25) TYPE c VALUE 'BILLING REFUNDS',    "Doc headertext"
             bschl(2) TYPE c VALUE '31',                  "Posting Key"
             hkont(7) TYPE n VALUE '490905',               "Account"
             name1(35) TYPE c,                            "Name"
             stras(35) TYPE c VALUE '66 Jorissen street', "Street"
             ort01(35) TYPE c VALUE 'JOHANNESBERG',       "City"
             pstlz(4) TYPE n VALUE '2001',                "Postal Code"
             wrbtr(16) ,                                  "Amount"
             mwskz(2) TYPE c VALUE 'V0',                  "Tax Code"
             zuonr(18) TYPE c,                            "Assignment"
             sgtxt(50) TYPE c,                            "Text"
             bschl1(2) TYPE c VALUE '40',                 "Posting Key"
             hkont1(7) TYPE n VALUE '8701120',            "Account"
             wrbtr1(16),                                  "Amount"
             zuonr1(18) TYPE c,                           "Assignment"
             sgtxt1(50) TYPE c,                            "Text"
           END OF it_process.
    *& BDC/Call transaction data.
    DATA: BEGIN OF bdcdata OCCURS 0.
            INCLUDE STRUCTURE bdcdata.
    DATA: END OF bdcdata.
    DATA: BEGIN OF it_error OCCURS 0,
          xblnr LIKE bkpf-xblnr,
          belnr LIKE bkpf-belnr,
          bldat LIKE bkpf-bldat,
          END OF it_error.
    *DATA: it_check LIKE bkpf OCCURS 0 WITH HEADER LINE.
    DATA: messtab LIKE bdcmsgcoll OCCURS 100 WITH HEADER LINE.
    DATA: lt_fldcat TYPE slis_t_fieldcat_alv,
          lt_errorcat TYPE slis_t_fieldcat_alv.
    DATA: BEGIN OF err_fld OCCURS 0,
          icon(8),
          rec_no(6) TYPE n,
          messg(100),
    END   OF err_fld.
    ===[DATA]=============================================================
    DATA: lv_subrc LIKE sy-subrc,
          f_session,
          f_session_created,
          lv_xblnr  LIKE bkpf-xblnr,
          lv_doc    LIKE bkpf-belnr,
          lt_files TYPE filetable,
          ls_files TYPE file_table,
          lv_return TYPE i,
          lv_filen TYPE string,
          lv_error,
          lv_repid LIKE sy-repid.
    DATA: lv_bldat(10),
          lv_budat(10).
    ===[STRUCTURES]=======================================================
    DATA: ls_fldcat TYPE slis_fieldcat_alv.
    *DATA: ls_fldcat1 TYPE slis_t_fieldcat_alv.
    DATA: ls_errorcat TYPE slis_fieldcat_alv.
    ===[SELECTION SCREEN]=================================================
    PARAMETERS:
      p_file  LIKE rlgrap-filename LOWER CASE OBLIGATORY.
    SELECTION-SCREEN SKIP.
    PARAMETERS:
      p_sess  LIKE d0100-mapn DEFAULT 'BILLING' OBLIGATORY.
    ===[AT SELECTION-SCREEN]==============================================
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      PERFORM get_file_name.
    ===[START-OF-SELECTION]===============================================
    START-OF-SELECTION.
    *& Upload file into internal table
      PERFORM fm_upload_file.
    *& Process file
      PERFORM fm_process_file.
    ===[END-OF-SELECTION]=================================================
    END-OF-SELECTION.
    IF lv_error <> space.
       PERFORM output_error_tab.
    ENDIF.
    SKIP.
    *& No data in file
      IF it_file_up[] IS INITIAL.
        MESSAGE s016(rp) WITH 'No data found in file'.
      ENDIF.
    *& Build catalog for column headings
      PERFORM fm_build_catalog.
    *& Displaying output in alv grid
      PERFORM fm_alv_grid_display.
    *& Build catalog for column headings
      PERFORM fm_error_catalog.
    *& Displaying output in alv grid
      PERFORM fm_error_grid_display.
    ===[FORMS]============================================================
    *&      Form  fm_process_file
          text
    FORM fm_process_file.
      PERFORM bdc_open_group.
      LOOP AT it_process.
        SELECT SINGLE *  FROM bkpf
         WHERE bukrs = '0100'
           AND blart = 'ZD'
           AND xblnr = it_process-xblnr.
        IF sy-subrc = 0.
          it_error-xblnr = bkpf-xblnr.
          it_error-belnr = bkpf-belnr.
          it_error-bldat = bkpf-bldat.
          APPEND it_error.
          CONTINUE.
        ENDIF.
        REFRESH bdcdata.
        CLEAR   bdcdata.
        CONCATENATE : it_process-bldat6(2)  '.' it_process-bldat4(2)  '.'
      it_process-bldat+0(4) INTO lv_bldat.
        CONCATENATE : it_process-budat6(2)  '.' it_process-budat4(2)  '.'
      it_process-budat+0(4) INTO lv_budat.
        PERFORM bdc_dynpro      USING 'SAPMF05A' '0100'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'RF05A-NEWKO'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '/00'.
        PERFORM bdc_field       USING 'BKPF-BLDAT'
                                      lv_bldat.
        PERFORM bdc_field       USING 'BKPF-BLART'
                                      'ZD'.
        PERFORM bdc_field       USING 'BKPF-BUKRS'
                                      '0100'.
        PERFORM bdc_field       USING 'BKPF-BUDAT'
                                      lv_budat.
        PERFORM bdc_field       USING 'BKPF-MONAT'
                                     '1'.
        PERFORM bdc_field       USING 'BKPF-WAERS'
                                      'ZAR'.
        PERFORM bdc_field       USING 'BKPF-XBLNR'
                                     it_process-xblnr.
        PERFORM bdc_field       USING 'BKPF-BKTXT'
                                      'BILLING REFUNDS'.
        PERFORM bdc_field       USING 'RF05A-NEWBS'
                                      '31'.
        PERFORM bdc_field       USING 'RF05A-NEWKO'
                                      '490900'.
        PERFORM bdc_dynpro      USING 'SAPLFCPD' '0100'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'BSEC-PSTLZ'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '/00'.
        PERFORM bdc_field       USING 'BSEC-NAME1'
                                      it_process-name1.
        PERFORM bdc_field       USING 'BSEC-STRAS'
                                      '66 JORISSEN STREET'.
        PERFORM bdc_field       USING 'BSEC-ORT01'
                                      'JOHANNESBURG'.
        PERFORM bdc_field       USING 'BSEC-PSTLZ'
                                      '2001'.
        PERFORM bdc_field       USING 'BSEC-LAND1'
                                      'ZA'.
        PERFORM bdc_dynpro      USING 'SAPMF05A' '0302'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'RF05A-NEWKO'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '/00'.
        PERFORM bdc_field       USING 'BSEG-WRBTR'
                                      it_process-wrbtr.
        PERFORM bdc_field       USING 'BSEG-MWSKZ'
                                      'V0'.
        PERFORM bdc_field       USING 'BSEG-ZUONR'
                                      it_process-zuonr.
        PERFORM bdc_field       USING 'BSEG-SGTXT'
                                      it_process-sgtxt.
        PERFORM bdc_field       USING 'RF05A-NEWBS'
                                      '40'.
        PERFORM bdc_field       USING 'RF05A-NEWKO'
                                      '8701120'.
        PERFORM bdc_dynpro      USING 'SAPMF05A' '0300'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'BSEG-SGTXT'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '/00'.
        PERFORM bdc_field       USING 'BSEG-WRBTR'
                                      it_process-wrbtr.
        PERFORM bdc_field       USING 'BSEG-ZUONR'
                                      it_process-zuonr.
        PERFORM bdc_field       USING 'BSEG-SGTXT'
                                      it_process-sgtxt.
        PERFORM bdc_field       USING 'DKACB-FMORE'
                                      'X'.
        PERFORM bdc_dynpro      USING 'SAPLKACB' '0002'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'COBL-KOSTL'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=ENTE'.
        PERFORM bdc_field       USING 'COBL-KOSTL'
                                      '444615'.
        PERFORM bdc_dynpro      USING 'SAPMF05A' '0300'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'BSEG-WRBTR'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=BU'.
        PERFORM bdc_field       USING 'BSEG-WRBTR'
                                      it_process-wrbtr.
        PERFORM bdc_field       USING 'BSEG-ZUONR'
                                      it_process-zuonr.
        PERFORM bdc_field       USING 'BSEG-SGTXT'
                                      it_process-sgtxt.
        PERFORM bdc_field       USING 'DKACB-FMORE'
                                      'X'.
        PERFORM bdc_dynpro      USING 'SAPLKACB' '0002'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'COBL-KOSTL'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      'ENTE'.
        PERFORM bdc_field       USING 'COBL-KOSTL'
                                      '21815'.
        PERFORM bdc_dynpro      USING 'SAPLKACB' '0002'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '/EESC'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'COBL-KOSTL'.
        PERFORM bdc_dynpro      USING 'SAPMF05A' '0700'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'RF05A-NEWBS'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      'RW'.
        PERFORM bdc_field       USING 'BKPF-XBLNR'
                                      it_process-xblnr.
        PERFORM bdc_field       USING 'BKPF-BKTXT'
                                      'BILLING REFUNDS'.
        PERFORM bdc_dynpro      USING 'SAPLSPO1' '0200'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=NO'.
        PERFORM bdc_dynpro      USING 'SAPMF05A' '0700'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'RF05A-NEWBS'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      'RW'.
        PERFORM bdc_field       USING 'BKPF-XBLNR'
                                      it_process-xblnr.
        PERFORM bdc_field       USING 'BKPF-BKTXT'
                                      'BILLING REFUNDS'.
        PERFORM bdc_dynpro      USING 'SAPLSPO1' '0200'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=YES'.
        PERFORM bdc_create_session.
      ENDLOOP.
      PERFORM bdc_close_session.
    ENDFORM.                    "fm_process_file
    *&      Form  bdc_dynpro
           Start new screen                                              *
         -->PROGRAM    text
         -->DYNPRO     text
    FORM bdc_dynpro USING program dynpro.
      CLEAR bdcdata.
      bdcdata-program  = program.
      bdcdata-dynpro   = dynpro.
      bdcdata-dynbegin = 'X'.
      APPEND bdcdata.
      CLEAR bdcdata.
    ENDFORM.                    "bdc_dynpro
    *&      Form  bdc_field
           Insert field                                                  *
         -->FNAM       text
         -->FVAL       text
    FORM bdc_field USING fnam fval.
      CLEAR bdcdata.
      bdcdata-fnam = fnam.
      bdcdata-fval = fval.
      APPEND bdcdata.
      CLEAR bdcdata.
    ENDFORM.                    "bdc_field
    *&      Form  bdc_create_session
          Create session
    FORM bdc_create_session.
      CALL FUNCTION 'BDC_INSERT'
        EXPORTING
          tcode            = 'F-02'
        TABLES
          dynprotab        = bdcdata
        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.
        lv_subrc = sy-subrc.
        MESSAGE i398(00) WITH 'Cannot insert BDC into session' p_sess
                              'Return code='                   lv_subrc.
      ENDIF.
    ENDFORM.                    " bdc_create_session
    *&      Form  bdc_close_session
          Close session
    FORM bdc_close_session.
      CALL FUNCTION 'BDC_CLOSE_GROUP'
        EXCEPTIONS
          not_open    = 1
          queue_error = 2
          OTHERS      = 3.
      IF sy-subrc <> 0.
        lv_subrc = sy-subrc.
        MESSAGE i398(00) WITH 'Cannot close session' p_sess
                              'Return code='         lv_subrc.
      ENDIF.
    ENDFORM.                    " bdc_close_session
    *&      Form  fm_build_catalog
          text
    FORM fm_build_catalog.
      ls_fldcat-fieldname = 'BLDAT'.
      ls_fldcat-ref_tabname = 'BKPF'.
      ls_fldcat-ref_fieldname = 'BLDAT'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'BLART'.
      ls_fldcat-ref_tabname = 'BKPF'.
      ls_fldcat-ref_fieldname = 'BLART'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'BUKRS'.
      ls_fldcat-ref_tabname = 'BKPF'.
      ls_fldcat-ref_fieldname = 'BUKRS'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'BUDAT'.
      ls_fldcat-ref_tabname = 'BKPF'.
      ls_fldcat-ref_fieldname = 'BUDAT'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'MONAT'.
      ls_fldcat-ref_tabname = 'BKPF'.
      ls_fldcat-ref_fieldname = 'MONAT'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'WAERS'.
      ls_fldcat-ref_tabname = 'BKPF'.
      ls_fldcat-ref_fieldname = 'WAERS'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'XBLNR'.
      ls_fldcat-ref_tabname = 'BKPF'.
      ls_fldcat-ref_fieldname = 'XBLNR'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'BKTXT'.
      ls_fldcat-ref_tabname = 'BKPF'.
      ls_fldcat-ref_fieldname = 'BKTXT'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'BSCHL'.
      ls_fldcat-ref_tabname = 'BSEG'.
      ls_fldcat-ref_fieldname = 'BSCHL'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'HKONT'.
      ls_fldcat-ref_tabname = 'BSEG'.
      ls_fldcat-ref_fieldname = 'HKONT'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'NAME1'.
      ls_fldcat-ref_tabname = 'BSEC'.
      ls_fldcat-ref_fieldname = 'NAME1'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'STRAS'.
      ls_fldcat-ref_tabname = 'BSEC'.
      ls_fldcat-ref_fieldname = 'STRAS'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'ORT01'.
      ls_fldcat-ref_tabname = 'BSEC'.
      ls_fldcat-ref_fieldname = 'ORT01'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'PSTLZ'.
      ls_fldcat-ref_tabname = 'BSEC'.
      ls_fldcat-ref_fieldname = 'PSTLZ'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'WRBTR'.
      ls_fldcat-ref_tabname = 'BSEG'.
      ls_fldcat-ref_fieldname = 'WRBTR'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'MWSKZ'.
      ls_fldcat-ref_tabname = 'BSEG'.
      ls_fldcat-ref_fieldname = 'MWSKZ'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'ZUONR'.
      ls_fldcat-ref_tabname = 'BSEG'.
      ls_fldcat-ref_fieldname = 'ZUONR'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'SGTXT'.
      ls_fldcat-ref_tabname = 'BSEG'.
      ls_fldcat-ref_fieldname = 'SGTXT'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'BSCHL1'.
      ls_fldcat-ref_tabname = 'ZBSEG'.
      ls_fldcat-ref_fieldname = 'BSCHL1'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'HKONT1'.
      ls_fldcat-ref_tabname = 'ZBSEG'.
      ls_fldcat-ref_fieldname = 'HKONT1'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'WRBTR'.
      ls_fldcat-ref_tabname = 'BSEG'.
      ls_fldcat-ref_fieldname = 'WRBTR'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'ZUONR'.
      ls_fldcat-ref_tabname = 'BSEG'.
      ls_fldcat-ref_fieldname = 'ZUONR'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'SGTXT'.
      ls_fldcat-ref_tabname = 'BSEG'.
      ls_fldcat-ref_fieldname = 'SGTXT'.
      APPEND ls_fldcat TO lt_fldcat.
    ENDFORM.                    "fm_build_catalog
    *&      Form  fm_error_catalog
          text
    FORM fm_error_catalog.
      ls_errorcat-fieldname = 'XBLNR'.
      ls_errorcat-ref_tabname = 'BKPF'.
      ls_errorcat-ref_fieldname = 'XBLNR'.
      APPEND ls_errorcat TO lt_errorcat.
      ls_errorcat-fieldname = 'BELNR'.
      ls_errorcat-ref_tabname = 'BKPF'.
      ls_errorcat-ref_fieldname = 'BELNR'.
      APPEND ls_errorcat TO lt_errorcat.
      ls_errorcat-fieldname = 'BLDAT'.
      ls_errorcat-ref_tabname = 'BKPF'.
      ls_errorcat-ref_fieldname = 'BLDAT'.
      APPEND ls_errorcat TO lt_errorcat.
    ENDFORM.                    "fm_error_catalog
    *&      Form  fm_alv_grid_display
          text
    FORM fm_alv_grid_display.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = lv_repid
          it_fieldcat        = lt_fldcat
        TABLES
          t_outtab           = it_process.
    ENDFORM.                    "fm_alv_grid_display
    *&      Form  fm_error_grid_display.
          text
    FORM fm_error_grid_display.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = lv_repid
          it_fieldcat        = lt_errorcat
        TABLES
          t_outtab           = it_error.
    ENDFORM.                    "fm_error_grid_display
    *&      Form  get_file_name
          Get file name
    FORM get_file_name.
    Select file
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        EXPORTING
          window_title            = 'Select File'
          default_extension       = 'Text Files (*.TXT)'
          file_filter             = cl_gui_frontend_services=>filetype_text
          initial_directory       = 'C:\'
        CHANGING
          file_table              = lt_files
          rc                      = lv_return
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          not_supported_by_gui    = 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.
      ELSE.
        READ TABLE lt_files INTO ls_files INDEX 1.
        p_file = ls_files-filename.
        CLEAR lt_files[].
      ENDIF.
    ENDFORM.                    " get_file_name
    *&      Form  fm_upload_file
          text
    FORM fm_upload_file.
      lv_filen = p_file.
    Upload file
      CALL METHOD cl_gui_frontend_services=>gui_upload
         EXPORTING
           filename                = lv_filen
         has_field_separator     = 'X'
         CHANGING
           data_tab                = it_file_up[]
         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
           not_supported_by_gui    = 17
           error_no_gui            = 18
           OTHERS                  = 19.
      IF sy-subrc <> 0.
        lv_subrc = sy-subrc.
        MESSAGE e398(00) WITH 'Cannot upload file:' p_file
                              'Return code='        lv_subrc.
      ENDIF.
    File did not upload or no data in file
      IF it_file_up[] IS INITIAL.
        STOP.
      ENDIF.
      LOOP AT it_file_up.
        CHECK it_file_up-ls_c2(4) = '9999'.
        it_file-bldat = it_file_up-bldat+0(8).  "Document Date"
        it_file-budat = it_file-bldat.          "Posting Date"
        it_file-xblnr = it_file_up-sgtxt+0(10).
        it_file-name1 = it_file_up-name1+0(35).  "Name"
        it_file-wrbtr = it_file_up-wrbtr+0(15).  "Amount"
        it_file-zuonr = it_file_up-zuonr+0(18).  "Assignment"
        it_file-sgtxt = it_file_up-sgtxt+0(10).  "Text"
        it_file-xblnr = it_file-xblnr.
        it_file-wrbtr1 = it_file-wrbtr.
        it_file-zuonr1 = it_file-zuonr.
        it_file-sgtxt1 = it_file-sgtxt.
        APPEND it_file.
      ENDLOOP.
      LOOP AT it_file.
        CHECK NOT it_file-bldat IS INITIAL.
        MOVE-CORRESPONDING it_file TO it_process.
        APPEND it_process.
      ENDLOOP.
    ENDFORM.                    " fm_upload_file
    *&      Form  bdc_open_group
          text
    -->  p1        text
    <--  p2        text
    FORM bdc_open_group .
      CALL FUNCTION 'BDC_OPEN_GROUP'
        EXPORTING
          group               = p_sess
          keep                = 'X'
          user                = sy-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.
      IF sy-subrc <> 0.
        lv_subrc = sy-subrc.
        MESSAGE i398(00) WITH 'Cannot open session' p_sess
                              'Return code='        lv_subrc.
        STOP.
      ENDIF.
    ENDFORM.                    " bdc_open_group
    anybody suggest me any other way to display error report.
    and sm35 logfile logic.

    Hi,
    1) if you want to create documents pls use abap rfbibl00 (here's a documentation) or fm BAPI_ACC_DOCUMENT_POST
    2) if you want to change header , use bdc to FB02;
       to item use FB09
    A.

  • File type in Session Method

    Hi All,
    This is in the session method in the upload function....
    I am getting error"""""Unable to interpret "FILE NAME".  Possible causes of error: incorrect spelling or comma error.""""" and the code is as follows..
    TO UPLOAD FLAT FILE TO INTERNAL TABLE.
    CALL FUNCTION 'UPLOAD'
    EXPORTING
    *CODEPAGE                      =''
       FILENAME                      = 'E:\RAJASAP\SELECTIONSCREEN.TXT'
       FILETYPE                      ='ASC'
      ITEM                          = ' '
    could any one help me in this issue.
    Message was edited by:
            Rajashekhar Reddy

    Hi Rajasekhar..
    See the Changes in BOLD
    CALL FUNCTION 'UPLOAD'
    <b>EXPORTING</b>    "you have to uncomment this..
    *CODEPAGE =''
    FILENAME = 'E:\RAJASAP\SELECTIONSCREEN.TXT'
    FILETYPE ='ASC'
    ITEM = ' '
    And one more thing
    Call the FM   GUI_UPLOAD instead of UPLOAD which is Obsolete .
    <b>Reward if Helpful</b>

  • Difference between call transaction and session method

    Hello Experts.
    i have one doubt.
    suppose if we have 100 records to upload, and we got an error in 55 record. In this case what will call trans will do and what will session will do.
    i mean the call trans will process 56th record or not . will it stop at 55 itself. What will session will do in this case.
    thank you so much for all the replies.

    Hi shiva,
    In the Call transaction Method,
    It will process all the records if the Update Mode is 'N', it will store all the error messages in BDCMSGCOLL structure. The errored records would be stored in that structure.
    In Session Method,
    It stops in the 55th error record, it wont move further.
    Edited by: Raj on May 21, 2008 9:23 PM

  • How to handle the errors in BDC Session method

    Hi All,
    I am uploading Material Master (MM01) records using BDC Session Method.my problem is when i am running the program, all the error records are going to flat file.how can i correcting the error records and after correction how can i re-process the error records.tell me with example.
    i have around 70,000 records in my flat file.

    Hi,
    I am attaching few threads.Hope these will help you.
    If there are any error records in session, all those error records will get poulated in log .SM35 and after the session is completed , u can see error records which can be corrected and reprocessed again
    We have the structures BDCLD and BDCLM, which will capture the log details inthe session. Firstly, sesssion should be processed. After that log will be created. Then caputure the information into an internal table using BDCLM and BDCLD.
    and refer the link.
    error correction in bdc session
    regards
    Madhu

Maybe you are looking for

  • Process Order Settlement posted with wrong amount to FI and COPA

    Experts, I have configured the system to post the production variance to FI and COPA with the help of allocation structure and PA transfer structure. Mat                    Text                                                                         

  • Emails deleted in exchange and advanced mailboxes stay on ipad and iPhone

    Hi I am having issues with emails that have been deleted from outlook (exchange profile) remaining in the inbox in the iPad and iPhone which is confusing at times. Any advIse would be appreciated. Karl

  • Apple TV lost network connections via ethernet again!

    It seems that here lately every time I go to use my Apple TV I have to do a restart because it has lost its internet connection. I have a 3rd gen device and it's wired via ethernet. This problem didn't start until the last firmware update and after r

  • What is a class library?

    can someone tell me what a class library is? examples would be helpful thanks

  • Dates off by exactly one month.  How do I fix this?

    The dates for my photos are off. Usually by exactly one month. This happens sometime after I import them. For example I took a photo at the my kid's last Soccer practice on November 6, 2007. I imported it on November 7th, 2007. And yet iPhoto '08 say