Call transaction in Background job

Hi,
I am executing a program in background. In that program I am having a CALL TRANSACTION as below:
CALL TRANSACTION 'ME22'
    USING g_t_bdctab
    MODE 'N'
    UPDATE 'S'
    MESSAGES into g_t_bdcmsg.
But it is not working. The same is working when the program is executed in foreground.
Is this means, we cannot have CALL TRANSACTION in background?
If Yes, then what could be the solution for it?
Thanks,
Pankaj.

Hello Pankaj,
Call transaction works in background.
Provided you are not picking file from presentation server.
If you are picking file from presentation server, place the same file in application server and during background job pick the file from application server then your program works perfectly.
Regards,
Tarun

Similar Messages

  • Require Job name in SM37 while executing call transaction in background

    Hi all,
    I am executing a report program, which contains Call transaction.
    I have recorded properly. The recording contains background job screen also ( means a separate popup came and i gave the job name and i gave immediately )
    When i execute in this program in foreground its creating job,its showing the job in sm37.
    But when i execute this program in background, it does not showing the job name in sm37.
    Anyone kindly help this out?
    Anandhab

    Hi,
    The job will be created by the step level user.
    Try searching again with jobname and * for username.
    Regards,
    Jovito

  • Call Transaction in background mode

    Hi everyone,
    What I am currently trying to do is to perform a 'call transaction' while forcing the 'background processing' mode even when the user is running the program in online mode; this allows me to retrieve a lot more messages that are useful to the user than the messages generated in online mode.
    As long as I have seen there is no field for that in the options table that can be passed to the 'call transaction' sentence. The only way to see that behavior while in online mode is by 'playing back' a recording thru the SHDB transaction and checking the 'Simulate background' option.
    My first attempt was to set the SY-BATCH flag before doing the call transaction but it doesn't work, the flag seems to reset itself with the correct value during the call.
    Any comments on this would be greatly appreciated.
    Regards,
    Sergio

    You would have to create a job on the fly to do this.  This example shows how to kick off a background job via an ABAP program.
    report zrich_0004 .
    data:   sdate type sy-datum,
            stime type sy-uzeit,
            l_valid,
            ls_params like pri_params,
            l_jobcount like tbtcjob-jobcount,
            l_jobname  like tbtcjob-jobname.
    start-of-selection.
    * Get Print Parameters
      call function 'GET_PRINT_PARAMETERS'
           exporting
                no_dialog      = 'X'
           importing
                valid          = l_valid
                out_parameters = ls_params.
    * Open Job
      l_jobname = 'ZRICH_0005'.
      call function 'JOB_OPEN'
           exporting
                jobname  = l_jobname
           importing
                jobcount = l_jobcount.
    * Submit report to job
      submit zrich_0005   
           via job     l_jobname
               number  l_jobcount
           to sap-spool without spool dynpro
               spool parameters ls_params
                  and return.
    * Schedule and close job.
      call function 'JOB_CLOSE'
           exporting
                jobcount  = l_jobcount
                jobname   = l_jobname
                strtimmed = 'X'

  • Call transaction in background in report

    I have a report in which I call a transaction, but the requirement is that I have to call it in background.
    Can you please suggest how I can achieve this.
    <removed_by_moderator>
    Edited by: Julius Bussche on Aug 26, 2008 3:20 PM

    Hi charles,
    Use the mode 'N'
    Example:-
    DATA:
      fs_opt TYPE ctu_params.
      fs_opt-dismode = 'N'.
        CALL TRANSACTION 'PA30'  USING t_bdcdata OPTIONS FROM fs_opt.
    Luck,
    Bhumika

  • CALL Transaction in background not working pls help URGENT

    hi i have writtin a bdc program which uses CALL TRSANCTION everything is working in foreground.
    if i schedule the program in background the call transaction does not work. any idea why?????????
    pls help its urgent

    hi
    good
    have you checked in the debug mode, if you have checked in the debug mode check wheather it is giving any error before data is displaying in the screen, if any error is displaying as a message than check that error why it is coming there.
    If no error is coming than check your flow of the bdc screen in the debug mode , there must be some prob, so that it is not working in the background.
    thanks
    mrutyun^

  • Call Transaction in Background for IW52

    Hi All..
    When i execute my BDC (Call Transaction) in foreground, the code will update IW52 screens without any errors/warnings.
    But if we schedule this in background, the IW52 screens are not getting updated.
    Even there are no Errors observed.
    We have used the syntax as follows..
    CALL Transaction IW52 using it_bdcdata MODE 'N' messages into it_bdcmsg.
    Can anyone help me how to rectify it and make it to execute successfully in background mode..??
    Your Help will be highly appreciated..
    Regards
    Pavan

    Hello Friends...
    I am running a call Transaction code in Background mode.
    I am facing Error message..
    If i run the same in foreground, it is working fine...
    Error Message is "No Batch Input data for screen <SAPNV screen No>"
    Expecting your guidence in this case...
    Regards
    Pavan
    Message was edited by:
            Pavan Sanganal

  • General BADi question:Call BADi in background job/batch input. Possible?

    Hi out there,
    i'm using thoe following BADi: /SAPSLL/CTRL_SD0C_R3 (Global Trade Service).
    But also, this question is a general question.
    If we are calling on screen the transaction VF01, the BADi is called correctly.
    But unfortunately it seemes that the BADi is NOT called (im not really sure, cause i can't debug the background task) when we are calling a batch input sequence wth f.e. form bdc_transaction VF01 nothing happens.
    Maybe BADi cannot be called in a background task? If it's possible, how could it be monitored. Thare isw no spool entry or anything like that!
    Any answer can help.
    Thank you in advance!
    Regards,
    Timo
    Edited by: Timo Ehl on Apr 14, 2009 7:27 PM

    Hi,
    generally BADIs are called in background mode. You can use the following trick to debug your BADI. You just need to create an infinite loop in your BADI implementation. Something like this.
    DATA: l_a TYPE c.
    WHILE l_a IS INITIAL.
    ENDWHILE.
    Obviously when your BADI is called in background mode then program will get into infinite loop. You can easily connect and debug running programs from transaction SM50. You need to select your background process and go to Program/Session -> Program -> Debugging. You will jump directly into your BADI methos with infinite loop. Then you will just set value to l_a and you will start debugging your BADI. If you can not find any process then your BADI is not called in background mode.
    Cheers

  • MIGO-Error when MIGO is execute by call transaction on background

    When we execute MIGO_TR or MIGO_GI in call transaction, this error is showed.
    "RAISE_EXCEPTION" " "                                                      
    "CL_GUI_CUSTOM_CONTAINER=======CP" or "CL_GUI_CUSTOM_CONTAINER=======CM001"
    "CONSTRUCTOR"  
    Is there any alternate function available for the MIGO  and avoiding the same error.
    Thanks in advance.
    Walter

    Hi Walter,
    MIGO is a SAP Enjoy transaction so BDC is not supported on the same.
    Regards,
    Atish

  • Call  transaction  inside  job

    hi all,
    I have  a call  transaction program for tcode ME55, the  probleme  is when  i  execute the  program  directly  via  se38  to  release the sales  documents it work  fine,   on the other hand when i call  the program  via SM37  nothing  will  happen.
    thanks,
    karim

    Hi,
    What exactly do you want to do by calling t.code me55 ? Upload some data in background or display the transaction to a user only ?
    If you want to do a call transaction in background, you will have to pass BDC data to it as well. Then transaction will run with the passed data then. To know what data to pass, simply record your transaction in SHDB T.code and create a program for the BDC.
    ME55 is a report, so perhaps you can use SUBMIT with the selection parameters in your program to be able run that program in background.
    regards,
    Advait

  • Timeout Error in Call Transaction on Asynchronous Abap Proxy

    Hi Gurus!!
    We have a problem with a Call Transaction on Asynchronous Abap Proxy. When the process of Call Transaction (transaction CO02) takes more than 10 minutes, the process is cancelled with sy-subrc 1001 and the Abap Proxy continues with the execution. Strangely, there is a short dump in ST22 on transaction CO02, although on the ABAP Proxy we don't get any dump.
    When this process is called from a Background Job no dumps are get.
    Somebody knows if there is a problem with the Asynchronous ABAP Proxy executing CALL TRANSACTION statementent?
    Thanks and regards,
    Manuel.

    and the message after recording is
    Number               1
    Transaction          F-22
    SY-SUBRC             0
    Messages
    FB01                SAPMF05A                                0301WEZ001                066
    FB01                SAPMF05A                                0300WEZ001                066
    FB01                SAPMF05A                                0300EEZ001                073
    I F5 573                   Correct the error reported before on the next screen
    FB01                SAPMF05A                                0300WEZ001                066
    FB01                SAPMF05A                                0300EEZ001                073
    I F5 573                   Correct the error reported before on the next screen
    FB01                SAPMF05A                                0330WEZ001                066
    FB01                SAPMF05A                                0301WEZ001                066
    FB01                SAPMF05A                                0301WEZ001                066
    FB01                SAPMF05A                                0301WEZ001                066
    S F5 312                   Document 100001677 was posted in company code 3100

  • Problem in Call Transsaction in background..

    Dear Friends ,
       I have written Call Transaction (BDC) inside the program.
    In output it will diaplays the document numbers and those document numbers r updated in one Tcode(through call transaction).
      if i run in Foregroung the documents numbers updating in that Tcode. but in Background it is not updating in that Tcode..
    What could b d probelm...

    Hi !
    Generally Call-Transaction in background is working fine...
    Check something out:
    - Do you get any errors back from the Call-Transaction ?
    - Does the background-user have permission do execute
      the called transaction ?
    - Is the update-task on the background-server running 
      (SM13) (If you have saparate server for background)
    - put an explicid COMMIT WORK after you call transaction
      (if you can do so). Commonly updatetask starts it's
      work by getting an COMMIT WORK.
      In dialog there's an implicid COMMIT WORK when
      then LIST oder the SELECTION-SCREEN apperas again.
    Regards
    Rainer
    Some points would be nice if that helped...

  • Can anybody pls tell me  limitations of BDC Session & Call transaction?

    hi, Guys, this is srinivas.
    How can we deside which method is to(BDC session/ Call transaction)
    use to upload data to SAP database?
    Can we run Call Transaction in Background?
    Which is preferable for bulk data? and Why?
    how can we restart Session if any error occurs?
    Thanku?

    Hi,
    Hope it helps this......
    SAP BDC INTERVIEW QUESTIONS  & ANSWERS
    1.       What is full form of BDC Session?
    Batch Data Communication Session.
    2.       What are the steps in a BDC session?
    The first step in a BDC session is to identify the screens of the transaction that the program will process.  Next step is to write a program to build the BDC table that will be used to submit the data to SAP.  The final step is to submit the BDC table to the system in the batch mode or as a single transaction by the CALL TRANSACTION command.
    3.       How do you find the information on the current screen?
    The information on the current screen can be found by SYSTEM à STATUS command from any menu.
    4.       How do you save data in BDC tables?
    The data in BDC tables is saved by using the field name ‘BDC_OKCODE’ and field value of ‘/11’.
    5.       What is the last entry in all BDC tables?
    In all BDC tables the last entry is to save the data by using the field name BDC_OKCODE and a field value of ‘/11’.
    6.       What is a multiple line field?
    A multiple line field is a special kind of field which allows the user to enter multiple lines of data into it.
    7.       How do you populate data into a multiple line field?
    To populate data into a multiple line field, an index is added to the field name to indicate which line is to be populated by the BDC session (Line index).
    8.       Write the BDC table structure.
    BDC table structure
    FIELD                     TYPE                            DESCRIPTION
    Program                CHAR (8)                      Program name of transaction.
    DynPro                 CHAR (4)                      Screen number of transaction.
    DynBegin              CHAR (1)                      Indicator for new screen.
    Fnam                    CHAR (35)                     Name of database field from screen.
    Fval                      CHAR (80)                     Value to submit to field.
    9.       Does the CALL TRANSACTION method allow multiple transactions to be processed by SAP?
    No.  The CALL TRANSACTION method allows only a single transaction to be processed by SAP.
    10.    Does the BDC-INSERT function allow multiple transactions to be processed by SAP?
    Yes.
    11.    What is the syntax for ‘CALL TRANSACTION’?
    CALL TRANSACTION trans .
    Three possible entries are there for MODE.
                      A          -           Show all screens.
                      E          -           Show only screens with errors.
                      N          -           Show no screens.
    Regards,
    V.Balaji
    Reward if usefull

  • Creating EXCEL documents and background jobs

    Hi there,
    I was wondering whether the method 'SAVE_DOCUMENT_TO_URL' of the interface 'i_oi_spreadsheet' will work when called in a background job with the intention to store the information somewhere on the SAP servers filepath ...
    If so then I would assume that one needs to install both SAPGUI and MS EXCEL on the server to get it actual working?
    Thx,
    Steven

    Yes it does seem silly that there is check like that.  However have a look at the first perform in the function: Create_Spreadsheet.  Right inside of that form there is another perform for get_spreadsheet_interface.  The following is the very first executable line in this perform:
    * don't do anything in batch, because there is no GUI...
      check sy-batch is initial.
    By exiting at this point, l_iref_spreadsheet will be initial and message e893(ux) will be issued.  Based upon that; the if sy-batch is initial around the SAPGUI_PROGRESS_INDICATOR call can never not be true.

  • Back ground ( Call Transaction) while running locking Tcode

    When iam running Call Transaction in background , suppose other user open ( it is giving popup like another user locked) transaction at that time i am getting created records sucessfully even it is not running Call trransaction can any body help me out.

    HI,
        when ever you are program is running that transaction for a specific order and other user tries to access this transaction and opens the same order it will give this error.
    Thanks
    Mahesh

  • Regarding call transaction and session method???

    HI All,
    Cud u pls let me know
    1. differences between call transaction and session???
    2. Is it possible to schedule call transaction in background?? ( all are saying MODE N = background scheduling  in call transaction.......but i dont think so)
    3. Is it posible to handle multiple transactions in call transaction ? if so,how?
    4. Is it posible to handle multiple transactions in session ? if so,how?
    5. How can we see the log in session method????

    Hi ,
    Check this documentation.
    About Session method
    In this method you transfer data from internal table to database table through sessions.
    In this method, an ABAP/4 program reads the external data that is to be entered in the SAP System and stores the data in session. A session stores the actions that are required to enter your data using normal SAP transaction i.e., Data is transferred to session which in turn transfers data to database table.
    Session is intermediate step between internal table and database table. Data along with its action is stored in session i.e., data for screen fields, to which screen it is passed, the program name behind it, and how the next screen is processed.
    When the program has finished generating the session, you can run the session to execute the SAP transactions in it. You can either explicitly start and monitor a session or have the session run in the background processing system.
    Unless session is processed, the data is not transferred to database table.
    BDC_OPEN_GROUP
    You create the session through program by BDC_OPEN_GROUP function.
    Parameters to this function are:
    • User Name: User name
    • Group: Name of the session
    • Lock Date: The date on which you want to process the session.
    • Keep: This parameter is passed as ‘X’ when you want to retain session after
    processing it or ‘ ‘ to delete it after processing.
    BDC_INSERT
    This function creates the session & data is transferred to Session.
    Parameters to this function are:
    • Tcode: Transaction Name
    • Dynprotab: BDC Data
    BDC_CLOSE_GROUP
    This function closes the BDC Group. No Parameters.
    Some additional information for session processing
    When the session is generated using the KEEP option within the BDC_OPEN_GROUP, the system always keeps the sessions in the queue, whether it has been processed successfully or not.
    However, if the session is processed, you have to delete it manually. When session processing is completed successfully while KEEP option was not set, it will be removed automatically from the session queue. Log is not removed for that session.
    If the batch-input session is terminated with errors, then it appears in the list of INCORRECT session and it can be processed again. To correct incorrect session, you can analyze the session. The Analysis function allows to determine which screen and value has produced the error. If you find small errors in data, you can correct them interactively, otherwise you need to modify batch input program, which has generated the session or many times even the data file.
    CALL TRANSACTION
    About CALL TRANSACTION
    A technique similar to SESSION method, while batch input is a two-step procedure, Call Transaction does both steps online, one after the other. In this method, you call a transaction from your program by
    Call transaction <tcode> using <BDCTAB>
    Mode <A/N/E>
    Update <S/A>
    Messages into <MSGTAB>.
    Parameter – 1 is transaction code.
    Parameter – 2 is name of BDCTAB table.
    Parameter – 3 here you are specifying mode in which you execute transaction
    A is all screen mode. All the screen of transaction are displayed.
    N is no screen mode. No screen is displayed when you execute the transaction.
    E is error screen. Only those screens are displayed wherein you have error record.
    Parameter – 4 here you are specifying update type by which database table is updated.
    S is for Synchronous update in which if you change data of one table then all the related Tables gets updated. And sy-subrc is returned i.e., sy-subrc is returned for once and all.
    A is for Asynchronous update. When you change data of one table, the sy-subrc is returned. And then updating of other affected tables takes place. So if system fails to update other tables, still sy-subrc returned is 0 (i.e., when first table gets updated).
    Parameter – 5 when you update database table, operation is either successful or unsuccessful or operation is successful with some warning. These messages are stored in internal table, which you specify along with MESSAGE statement. This internal table should be declared like BDCMSGCOLL, a structure available in ABAP/4. It contains the following fields:
    1. Tcode: Transaction code
    2. Dyname: Batch point module name
    3. Dynumb: Batch input Dyn number
    4. Msgtyp: Batch input message type (A/E/W/I/S)
    5. Msgspra: Batch input Lang, id of message
    6. Msgid: Message id
    7. MsgvN: Message variables (N = 1 - 4)
    For each entry, which is updated in database, table message is available in BDCMSGCOLL. As BDCMSGCOLL is structure, you need to declare a internal table which can contain multiple records (unlike structure).
    Steps for CALL TRANSACTION method
    1. Internal table for the data (structure similar to your local file)
    2. BDCTAB like BDCDATA
    3. UPLOAD or WS_UPLOAD function to upload the data from local file to itab. (Considering file is local file)
    4. Loop at itab.
    Populate BDCTAB table.
    Call transaction <tcode> using <BDCTAB>
    Mode <A/N/E>
    Update <S/A>.
    Refresh BDCTAB.
    Endloop.
    (To populate BDCTAB, You need to transfer each and every field)
    The major differences between Session method and Call transaction are as follows:
    SESSION METHOD CALL TRANSACTION
    1. Data is not updated in database table unless Session is processed. Immediate updation in database table.
    2. No sy-subrc is returned. Sy-subrc is returned.
    3. Error log is created for error records. Errors need to be handled explicitly
    4. Updation in database table is always synchronous Updation in database table can be synchronous Or Asynchronous.
    Error Handling in CALL TRANSACTION
    When Session Method updates the records in database table, error records are stored in the log file. In Call transaction there is no such log file available and error record is lost unless handled. Usually you need to give report of all the error records i.e., records which are not inserted or updated in the database table. This can be done by the following method:
    Steps for the error handling in CALL TRANSACTION
    1. Internal table for the data (structure similar to your local file)
    2. BDCTAB like BDCDATA
    3. Internal table BDCMSG like BDCMSGCOLL
    4. Internal table similar to Ist internal table
    (Third and fourth steps are for error handling)
    5. UPLOAD or WS_UPLOAD function to upload the data from the local file to itab. (Considering file is local file)
    6. Loop at itab.
    Populate BDCTAB table.
    Call transaction <tr.code> using <Bdctab>
    Mode <A/N/E>
    Update <S/A>
    Messages <BDCMSG>.
    Perform check.
    Refresh BDCTAB.
    Endloop.
    7 Form check.
    IF sy-subrc <> 0. (Call transaction returns the sy-subrc if updating is not successful).
    Call function Format_message.
    (This function is called to store the message given by system and to display it along with record)
    Append itab2.
    Display the record and message.
    Check this program for session method using multiple transactions.
    Have one BDC_OPEN_GROUP, multiple BDC_INSERT s and one BDC_CLOSE_GROUP.
    You should have multiple BDC_INSERT s for multiple transactions.
    call function BDC_OPENGROUP.
    Build BDC data and cal lBDC_INSERT for transaction 1
    Build BDC data and cal lBDC_INSERT for transaction 2
    Build BDC data and cal lBDC_INSERT for transaction 3
    call function BDC_CLOSE_GROUP.
    Check out this sample program
    REPORT  ztest_report
    NO STANDARD PAGE HEADING
                            LINE-SIZE 255
                            MESSAGE-ID ZRASH.
                    Internal Table Declarations                          *
    *--Internal Table for Data Uploading.
    DATA : BEGIN OF IT_FFCUST OCCURS 0,
             KUNNR(10),
             BUKRS(4),
             KTOKD(4),
             ANRED(15),
             NAME1(35),
             SORTL(10),
             STRAS(35),
             ORT01(35),
             PSTLZ(10),
             LAND1(3),
             SPRAS(2),
             AKONT(10),
           END OF IT_FFCUST.
    *--Internal Table to Store Error Records.
    DATA : BEGIN OF IT_ERRCUST OCCURS 0,
             KUNNR(10),
             EMSG(255),
           END OF IT_ERRCUST.
    *--Internal Table to Store Successful Records.
    DATA : BEGIN OF IT_SUCCUST OCCURS 0,
             KUNNR(10),
             SMSG(255),
           END OF IT_SUCCUST.
    *--Internal Table for Storing the BDC data.
    DATA : IT_CUSTBDC LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
    *--Internal Table for storing the messages.
    DATA : IT_CUSTMSG LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
    DATA : V_FLAG1(1) VALUE ' ',
    "Flag used for opening session.
           V_TLINES LIKE SY-TABIX,
           "For storing total records processed.
           V_ELINES LIKE SY-TABIX,
           "For storing the no of error records.
           V_SLINES LIKE SY-TABIX.
           "For storing the no of success records.
             Selection screen                                            *
    SELECTION-SCREEN BEGIN OF BLOCK B1.
    PARAMETERS : V_FNAME LIKE RLGRAP-FILENAME,
                 V_SESNAM  LIKE RLGRAP-FILENAME.
    SELECTION-SCREEN END OF BLOCK B1.
             Start-of-selection                                          *
    START-OF-SELECTION.
    *-- Form to upload flatfile data into the internal table.
      PERFORM FORM_UPLOADFF.
           TOP-OF-PAGE                                                   *
    TOP-OF-PAGE.
      WRITE:/ 'Details of the error and success records for the transaction'
      ULINE.
      SKIP.
             End of Selection                                            *
    END-OF-SELECTION.
    *-- Form to Generate a BDC from the Uploaded Internal table
      PERFORM FORM_BDCGENERATE.
    *--To write the totals and the session name.
      PERFORM FORM_WRITEOP.
    *&      Form  form_uploadff
        Form to upload flatfile data into the internal table.
    FORM FORM_UPLOADFF .
    *--Variable to change the type of the parameter file name.
      DATA : LV_FILE TYPE STRING.
      LV_FILE = V_FNAME.
    *--Function to upload the flat file to the internal table.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME                      =  LV_FILE
        FILETYPE                      = 'ASC'
          HAS_FIELD_SEPARATOR           = 'X'
        HEADER_LENGTH                 = 0
        READ_BY_LINE                  = 'X'
        DAT_MODE                      = ' '
      IMPORTING
        FILELENGTH                    =
        HEADER                        =
        TABLES
          DATA_TAB                      = IT_FFCUST
        EXCEPTIONS
          FILE_OPEN_ERROR               = 1
          FILE_READ_ERROR               = 2
          NO_BATCH                      = 3
          GUI_REFUSE_FILETRANSFER       = 4
          INVALID_TYPE                  = 5
          NO_AUTHORITY                  = 6
          UNKNOWN_ERROR                 = 7
          BAD_DATA_FORMAT               = 8
          HEADER_NOT_ALLOWED            = 9
          SEPARATOR_NOT_ALLOWED         = 10
          HEADER_TOO_LONG               = 11
          UNKNOWN_DP_ERROR              = 12
          ACCESS_DENIED                 = 13
          DP_OUT_OF_MEMORY              = 14
          DISK_FULL                     = 15
          DP_TIMEOUT                    = 16
          OTHERS                        = 17
      IF SY-SUBRC = 0.
    *--Deleting the headings from the internal table.
        DELETE IT_FFCUST INDEX 1.
    *--Getting the total number of records uploaded.
        DESCRIBE TABLE IT_FFCUST LINES V_TLINES.
      ENDIF.
    ENDFORM.                    " form_uploadff
    *&      Form  Form_bdcgenerate
        Form to Generate a BDC from the Uploaded Internal table
    FORM FORM_BDCGENERATE .
    *--Generating the BDC table for the fields of the internal table.
      LOOP AT IT_FFCUST.
        PERFORM POPULATEBDC USING :
                                    'X' 'SAPMF02D' '0105',
                                    ' ' 'BDC_OKCODE'  '/00' ,
                                    ' ' 'RF02D-KUNNR' IT_FFCUST-KUNNR,
                                    ' ' 'RF02D-BUKRS' IT_FFCUST-BUKRS,
                                    ' ' 'RF02D-KTOKD' IT_FFCUST-KTOKD,
                                    'X' 'SAPMF02D' '0110' ,
                                    ' ' 'BDC_OKCODE'  '/00',
                                    ' ' 'KNA1-ANRED'  IT_FFCUST-ANRED,
                                    ' ' 'KNA1-NAME1' IT_FFCUST-NAME1,
                                    ' ' 'KNA1-SORTL'  IT_FFCUST-SORTL,
                                    ' ' 'KNA1-STRAS' IT_FFCUST-STRAS,
                                    ' ' 'KNA1-ORT01' IT_FFCUST-ORT01,
                                    ' ' 'KNA1-PSTLZ' IT_FFCUST-PSTLZ,
                                    ' ' 'KNA1-LAND1' IT_FFCUST-LAND1,
                                    ' ' 'KNA1-SPRAS' IT_FFCUST-SPRAS,
                                    'X' 'SAPMFO2D' '0120',     
                                    ' ' 'BDC_OKCODE'  '/00',
                                    'X' 'SAPMF02D' '0125',     
                                    ' ' 'BDC_OKCODE'  '/00',
                                    'X' 'SAPMF02D' '0130',     
                                    ' ' 'BDC_OKCODE'  '=ENTR',
                                    'X' 'SAPMF02D' '0340',     
                                    ' ' 'BDC_OKCODE'  '=ENTR',
                                    'X' 'SAPMF02D' '0360',
                                    ' ' 'BDC_OKCODE'  '=ENTR',
                                    'X' 'SAPMF02D' '0210',     
                                    ' ' 'KNB1-AKONT'  IT_FFCUST-AKONT,
                                    ' ' 'BDC_OKCODE'  '/00',
                                    'X' 'SAPMF02D' '0215',
                                    ' ' 'BDC_OKCODE'  '/00',
                                    'X' 'SAPMF02D' '0220',     
                                    ' ' 'BDC_OKCODE'  '/00',
                                    'X' 'SAPMF02D' '0230',     
                                    ' ' 'BDC_OKCODE'  '=UPDA'.
    *--Calling the transaction 'fd01'.
        CALL TRANSACTION 'FD01' USING IT_CUSTBDC MODE 'N' UPDATE 'S'
        MESSAGES INTO IT_CUSTMSG.
        IF SY-SUBRC <> 0.
    *--Populating the error records internal table.
          IT_ERRCUST-KUNNR = IT_FFCUST-KUNNR.
          APPEND IT_ERRCUST.
          CLEAR IT_ERRCUST.
    *--Opening a session if there is an error record.
          IF V_FLAG1 = ' '.
            PERFORM FORM_OPENSESSION.
            V_FLAG1 = 'X'.
          ENDIF.
    *--Inserting the error records into already open session.
          IF V_FLAG1 = 'X'.
            PERFORM FORM_INSERT.
          ENDIF.
    *--Populating the Success records internal table.
        ELSE.
          IT_SUCCUST-KUNNR = IT_FFCUST-KUNNR.
          APPEND IT_SUCCUST.
          CLEAR IT_SUCCUST.
        ENDIF.
    *--Displaying the messages.
        IF NOT IT_CUSTMSG[] IS INITIAL.
          PERFORM FORM_FORMATMSG.
        ENDIF.
    *--Clearing the message and bdc tables.
        CLEAR : IT_CUSTBDC[],IT_CUSTMSG[].
      ENDLOOP.
    *--Getting the total no of error records.
      DESCRIBE TABLE IT_ERRCUST LINES V_ELINES.
    *--Getting the total no of successful records.
      DESCRIBE TABLE IT_SUCCUST LINES V_SLINES.
    *--Closing the session only if it is open.
      IF V_FLAG1 = 'X'.
        PERFORM FORM_CLOSESESS.
      ENDIF.
    ENDFORM.                    " Form_bdcgenerate
    *&      Form  populatebdc
          FOrm to Populate the BDC table.
    FORM POPULATEBDC  USING    VALUE(P_0178)
                               VALUE(P_0179)
                               VALUE(P_0180).
      IF P_0178 = 'X'.
        IT_CUSTBDC-PROGRAM = P_0179.
        IT_CUSTBDC-DYNPRO = P_0180.
        IT_CUSTBDC-DYNBEGIN = 'X'.
      ELSE.
        IT_CUSTBDC-FNAM = P_0179.
        IT_CUSTBDC-FVAL = P_0180.
      ENDIF.
      APPEND IT_CUSTBDC.
      CLEAR IT_CUSTBDC.
    ENDFORM.                    " populatebdc
    *&      Form  FORM_OPENSESSION
          Form to Open a session.
    FORM FORM_OPENSESSION .
    *--Variable to convert the given session name into reqd type.
      DATA : LV_SESNAM(12).
      LV_SESNAM = V_SESNAM.
    *--Opening a session.
      CALL FUNCTION 'BDC_OPEN_GROUP'
       EXPORTING
         CLIENT                    = SY-MANDT
         GROUP                     = LV_SESNAM
         HOLDDATE                  = '20040805'
         KEEP                      = 'X'
         USER                      = SY-UNAME
         PROG                      = SY-CPROG
    IMPORTING
       QID                       =
       EXCEPTIONS
         CLIENT_INVALID            = 1
         DESTINATION_INVALID       = 2
         GROUP_INVALID             = 3
         GROUP_IS_LOCKED           = 4
         HOLDDATE_INVALID          = 5
         INTERNAL_ERROR            = 6
         QUEUE_ERROR               = 7
         RUNNING                   = 8
         SYSTEM_LOCK_ERROR         = 9
         USER_INVALID              = 10
         OTHERS                    = 11
      IF SY-SUBRC <> 0.
        WRITE :/ 'Session not open'.
      ENDIF.
    ENDFORM.                    " FORM_OPENSESSION
    *&      Form  FORM_INSERT
          fORM TO INSERT ERROR RECOED INTO A SESSION.
    FORM FORM_INSERT .
    *--Inserting the record into session.
      CALL FUNCTION 'BDC_INSERT'
        EXPORTING
          TCODE                  = 'FD01'
        POST_LOCAL             = NOVBLOCAL
        PRINTING               = NOPRINT
        SIMUBATCH              = ' '
        CTUPARAMS              = ' '
        TABLES
          DYNPROTAB              = IT_CUSTBDC
        EXCEPTIONS
          INTERNAL_ERROR         = 1
          NOT_OPEN               = 2
          QUEUE_ERROR            = 3
          TCODE_INVALID          = 4
          PRINTING_INVALID       = 5
          POSTING_INVALID        = 6
          OTHERS                 = 7
      IF SY-SUBRC <> 0.
        WRITE :/ 'Unable to insert the record'.
      ENDIF.
    ENDFORM.                    " FORM_INSERT
    *&      Form  FORM_CLOSESESS
          Form to Close the Open Session.
    FORM FORM_CLOSESESS .
      CALL FUNCTION 'BDC_CLOSE_GROUP'
        EXCEPTIONS
          NOT_OPEN    = 1
          QUEUE_ERROR = 2
          OTHERS      = 3.
      IF SY-SUBRC <> 0.
      ENDIF.
    ENDFORM.                    " FORM_CLOSESESS
    *&      Form  FORM_FORMATMSG
          Form to format messages.
    FORM FORM_FORMATMSG .
    *--Var to store the formatted msg.
      DATA : LV_MSG(255).
      CALL FUNCTION 'FORMAT_MESSAGE'
        EXPORTING
          ID        = SY-MSGID
          LANG      = SY-LANGU
          NO        = SY-MSGNO
          V1        = SY-MSGV1
          V2        = SY-MSGV2
          V3        = SY-MSGV3
          V4        = SY-MSGV4
        IMPORTING
          MSG       = LV_MSG
        EXCEPTIONS
          NOT_FOUND = 1
          OTHERS    = 2.
      IF SY-SUBRC = 0.
        WRITE :/ LV_MSG.
      ENDIF.
      ULINE.
    ENDFORM.                    " FORM_FORMATMSG
    *&      Form  form_writeop
          To write the totals and the session name.
    FORM FORM_WRITEOP .
      WRITE :/ 'Total Records Uploaded :',V_TLINES,
               / 'No of Error Records :',V_ELINES,
               / 'No of Success Records :',V_SLINES,
               / 'Name of the Session :',V_SESNAM.
      ULINE.
    ENDFORM.                    " form_writeop
    Hope this resolves your query.
    Reward all the helpful answers.
    Regards

Maybe you are looking for