Function Module to Execute the task backgroundly

HI gurus
    I need to execute the workitem programatically which is possible in the SAP_WAPI_SET_WORKITEM_STATUS but I need the wiresult as 001 or 002 or 003 because this workitem task as decision task. So how I have to handle either through any FM or any coding. Please let me know the FM or codes.
Thanks,
Velu...

I think you should use SAP_WAPI_DECISION_COMPLETE Function module
WI_RESULT  field stores the unique value for each decision option.
Thanks
Arghadip

Similar Messages

  • Function module to execute the session

    Hi All,
    I want to know the function module to execute the session created in sm35.

    Hi,
    bdc_open_group:
    this function module is used to open the session.
    parameters related to this function module are
    client:sy-mandt
    uname:sy-uname
    holddate:sy-datum
    group: <groupname>
    keep: 'X' / ' '.
    2)bdc_insert:this function module is used to insert the
    values to the session
    parameters related to bdc_insert are
    tcode: mention the transaction code
    dynprotab: mention the internal table having structure like bdcdata.
    3)bdc_close_group:
    when ever u open the session it is must to close the session
    Hope it helps you.
    Regards Mansi

  • Function module to execute the program in the background.

    Hi Experts,
         I have two reports i am calling report2 from report1. Here the problem is i wanted to pass the input parameters using the "submit" statement and i wanted only one field value from the report2... whcih is used in report1 and i dont wanted to display the selection screen or output of report2. i am using the submit and return and i am unable to get it... can any one suggest and send me a peace of code.. for this...
    he would be rewarded
    Regards,
    Rajashekahr.A

    if you don't want the selection screen or the output...you can use the option
    SUBMIT <RPT> EXPORTING LIST TO MEMORY AND RETURN
    this will directly execute the report without showing you the selection screen or the output..
    now you also want a value from report 2 into report1...you can set the value from report 2 into a memory variable..using EXPORT to memory id option....
    hope it helps

  • Modified Functional module not executing the inserted Code

    Hi everyone
    I've modified the IW_C_CREATE_TRANSPORT_REQUEST Functional module so that it calls the GUI_EXEC FM which calles my java script which saves the transport ID with a filename specified. The code seems to work when i test it within SAP, but when i come to use STARTRFC to call the function, the added code dosen't seem to be executing, the transport still gets created but my javascript is not being called?
    Anyone know why?
    Thanks - Peter
    Code following
    FUNCTION IW_C_CREATE_TRANSPORT_REQUEST.
    ""Local interface:
    *"  IMPORTING
    *"     VALUE(DESCRIPTION) LIKE  E07T-AS4TEXT
    *"     VALUE(TRANSPORT_KIND) LIKE  E070-TRFUNCTION DEFAULT 'K'
    *"     VALUE(LANGU) LIKE  SY-LANGU DEFAULT 'EN'
    *"     VALUE(CQ_ID) LIKE  E070-TRKORR DEFAULT 'FileName'
    *"  EXPORTING
    *"     VALUE(COMMFILE) LIKE  E070-TRKORR
    *"     VALUE(PROG_PATH) LIKE  E070-TRKORR
    *"     VALUE(CLASSNAME) LIKE  E07T-AS4TEXT
    *"  EXCEPTIONS
    *"      LANGUAGE_MISSING
    *"      NUMBER_RANGE_FULL
    *"      UNALLOWED_TRFUNCTION
    *"      NO_AUTHORIZATION
    *"      CREATE_TRANSPORT_ERROR
    CLEAR COMMFILE.
    CASE TRANSPORT_KIND.
      WHEN 'P'.
    Stücklisten für Releasewechsel
        IF NOT LANGU IS INITIAL.
          PERFORM CREATE_RELEASE_REQUEST
            USING    LANGU
                     DESCRIPTION
                     TRANSPORT_KIND
            CHANGING COMMFILE.
        ELSE.
        keine Sprache angegeben und Transportart Stücklisten
          RAISE LANGUAGE_MISSING.
        ENDIF.
      WHEN OTHERS.
    Alle anderen Transporte
      PERFORM CREATE_REQUEST
        USING    DESCRIPTION
                 TRANSPORT_KIND
        CHANGING COMMFILE.
    ENDCASE.
    *{ INSERT SM1K900042 1
    WRITE 'Entering My Pogram'.
    PROG_PATH = 'java.exe'.
    CLASSNAME = '-cp c: writeToFile'.
    CONDENSE CLASSNAME.
    CONDENSE PROG_PATH.
    CONCATENATE CLASSNAME CQ_ID COMMFILE INTO CLASSNAME SEPARATED BY ' '.
    CALL FUNCTION 'GUI_EXEC'
    EXPORTING
    PARAMETER = CLASSNAME
    COMMAND = PROG_PATH.
    WRITE 'Our path is'.
    WRITE PROG_PATH.
    WRITE CLASSNAME.
    *} INSERT
    ENDFUNCTION.
    *************************FORMS****************************************
          FORM CREATE_RELEASE_REQUEST                                    *
    Transportauftrag für Stücklisten erstellen                           *
    FORM CREATE_RELEASE_REQUEST
      USING    P_LANGU              LIKE SY-LANGU
               P_TRANSPORT_DESCRIPT LIKE E07T-AS4TEXT
               P_TRANS_KIND         LIKE E070-TRFUNCTION
      CHANGING P_COMMFILE           LIKE E070-TRKORR.
      DATA: SUBRC         LIKE SY-SUBRC,
            H_TMP_LANG(2) TYPE C,
            H_NUMBER(3)   TYPE C,
            NUMBER(4)     TYPE C.
    Anwednungslog öffnen
      PERFORM OPEN_LOG
        USING P_TRANSPORT_DESCRIPT.
    *Nummer ziehen
      PERFORM GET_NUMBER USING    P_LANGU
                         CHANGING H_NUMBER
                                  SUBRC.
      IF     SUBRC = 12.
    Fehler beim erstellen des Transportauftrags
        RAISE CREATE_TRANSPORT_ERROR.
      ELSEIF SUBRC = 11.
    Nummernkreis voll
        RAISE NUMBER_RANGE_FULL.
      ELSE.
        WRITE P_LANGU TO H_TMP_LANG.
        P_COMMFILE = 'SAPKXXXLYY'.
        REPLACE 'XXX' WITH H_NUMBER     INTO P_COMMFILE.
        REPLACE 'YY'  WITH H_TMP_LANG   INTO P_COMMFILE.
        CALL FUNCTION 'SUBST_CREATE_COMMANDFILE'
             EXPORTING
                  IV_KORRNAME          = P_COMMFILE
                  IV_KORRTYPE          = P_TRANS_KIND
                  IV_KORRTEXT          = P_TRANSPORT_DESCRIPT
             EXCEPTIONS
                  NAME_COLLISION       = 1
                  CREATE_HEADER_FAILED = 2
                  UPDATE_HEADER_FAILED = 3
                  OTHERS               = 4.
        IF SY-SUBRC <> 0.
          CLEAR P_COMMFILE.
        Fehler beim Erstellen des Transportauftrags
          RAISE CREATE_TRANSPORT_ERROR.
        ELSE.
        Transportauftrag erstellt
        Log schreiben
          PERFORM WRITE_LOGFILE
            USING P_COMMFILE.
        ENDIF.
      ENDIF.
    ENDFORM.                               "CREATE_RELEASE_REQUEST
          FORM CREATE_REQUEST                                            *
    Transportauftrag erstellen                                           *
    FORM CREATE_REQUEST
      USING    P_TRANSPORT_DESCRIPT LIKE E07T-AS4TEXT
               P_TRANS_KIND         LIKE E070-TRFUNCTION
      CHANGING P_COMMFILE           LIKE E070-TRKORR.
      CALL FUNCTION 'TRINT_INSERT_NEW_COMM'
           EXPORTING
                WI_KURZTEXT   = P_TRANSPORT_DESCRIPT
                WI_TRFUNCTION = P_TRANS_KIND
           IMPORTING
                WE_TRKORR     = P_COMMFILE
           EXCEPTIONS
             NUMBER_RANGE_FULL       = 1
             INVALID_INPUT           = 2
             NO_AUTHORIZATION        = 3
             OTHERS                  = 4.
      CASE SY-SUBRC.
        WHEN 0.
      Auftrag erstellt
      Anwednungslog öffnen
          PERFORM OPEN_LOG
            USING P_TRANSPORT_DESCRIPT.
      Log schreiben
          PERFORM WRITE_LOGFILE
            USING P_COMMFILE.
        WHEN 1.                             "Nummernkreis für Aufträge voll
          CLEAR P_COMMFILE.
          RAISE NUMBER_RANGE_FULL.
         p_error_msg-no = '735'.
        WHEN 2.                             "Unbekannter Auftragstyp
          CLEAR P_COMMFILE.
          RAISE UNALLOWED_TRFUNCTION.
         p_error_msg-no = '353'.
        WHEN 3.                             "keine Berechtigung
          CLEAR P_COMMFILE.
          RAISE NO_AUTHORIZATION.
         p_error_msg-no = '328'.
        WHEN 4.                             "Allgemeiner Fehler
          CLEAR P_COMMFILE.
          RAISE CREATE_TRANSPORT_ERROR.
         p_error_msg-no = '353'.
      ENDCASE.
    ENDFORM.                               "create_request
    FORM OPEN_LOG                                                        *
    Anwedungslog öffnen                                                  *
    FORM OPEN_LOG
      USING P_TRANSPORT_DESCRIPT LIKE E07T-AS4TEXT.
    *init application log
      PERFORM LOG_INIT USING C_APPL_LOG_TRANSPORT.
    *log header
      PERFORM LOG_HEADER
        USING C_APPL_LOG_TRANSPORT P_TRANSPORT_DESCRIPT.
    ENDFORM.                             "OPEN_LOG
    FORM WRITE_LOGFILE                                                   *
    Logfile in den Anwendungslog schreiben                               *
    -> P_TRANSPORT_DESCRIPT                                              *
    FORM WRITE_LOGFILE
      USING P_COMMFILE           LIKE E070-TRKORR.
    DATA: H_ERROR_MSG LIKE IWERRORMSG.
    *log message transport created
      CLEAR H_ERROR_MSG.
      MOVE '42'  TO H_ERROR_MSG-ID.
      MOVE 'I'   TO H_ERROR_MSG-TYPE.
      MOVE '733' TO H_ERROR_MSG-NO.
      MOVE P_COMMFILE TO H_ERROR_MSG-V1.
      PERFORM LOG_MSG
        USING C_APPL_LOG_TRANSPORT '2' H_ERROR_MSG.
    *log save
      PERFORM LOG_SAVE
        USING C_APPL_LOG_TRANSPORT.
    ENDFORM.              "WRITE_LOGFILE
          FORM GET_NUMBER                                               *
    -->  LANGU                                                         *
    -->  NUMBER                                                        *
    FORM GET_NUMBER
      USING    LANGU   LIKE SY-LANGU
      CHANGING NUMBER  TYPE C
               SUBRC   LIKE SY-SUBRC.
      CONSTANTS: OBJECT LIKE INRI-OBJECT VALUE 'SIWBTRANSP'.
      DATA: NR_RANGE LIKE INRI-NRRANGENR,
            RETURNCODE LIKE  INRI-RETURNCODE,
            ERROR_MSG LIKE IWERRORMSG.
      CLEAR SUBRC.
      NR_RANGE = '01'.
      CALL FUNCTION 'NUMBER_GET_NEXT'
           EXPORTING
                NR_RANGE_NR             = NR_RANGE
                OBJECT                  = OBJECT
                SUBOBJECT               = LANGU
           IMPORTING
                NUMBER                  = NUMBER
                RETURNCODE              = RETURNCODE
           EXCEPTIONS
                INTERVAL_NOT_FOUND      = 1
                NUMBER_RANGE_NOT_INTERN = 2
                OBJECT_NOT_FOUND        = 3
                QUANTITY_IS_0           = 4
                QUANTITY_IS_NOT_1       = 5
                INTERVAL_OVERFLOW       = 6
                OTHERS                  = 7.
      CASE SY-SUBRC.
        WHEN 00.
        WHEN 01.
          PERFORM NUMBER_RANGE_INTERVAL_INSERT
                  USING      NR_RANGE  LANGU
                  CHANGING   NUMBER
                             RETURNCODE.
        WHEN OTHERS.
          SUBRC = 12.
          PERFORM FILL_ERROR_MSG
            USING    C_MESSAGE_ERROR 736 SY-SUBRC SPACE SPACE SPACE
            CHANGING ERROR_MSG.
          PERFORM LOG_MSG USING C_APPL_LOG_TRANSPORT 1 ERROR_MSG.
      ENDCASE.
      CASE RETURNCODE.
        WHEN ' '.
        WHEN '1'.                          "Nummer im kritischen Bereich
          PERFORM FILL_ERROR_MSG
            USING    C_MESSAGE_INFO 734 SPACE SPACE SPACE SPACE
            CHANGING ERROR_MSG.
          PERFORM LOG_MSG USING C_APPL_LOG_TRANSPORT 2 ERROR_MSG.
        WHEN '2'.                          "letzte Nummer vergeben
          PERFORM FILL_ERROR_MSG
            USING    C_MESSAGE_INFO 735 SPACE SPACE SPACE SPACE
            CHANGING ERROR_MSG.
          PERFORM LOG_MSG USING C_APPL_LOG_TRANSPORT 1 ERROR_MSG.
          SUBRC = 11.
      ENDCASE.
    ENDFORM.                               "number_get
    Message was edited by:
            Peter Lai

    Hi i've tried restarting and starting the server, but it didn't help, would it have anything to do with the fact i'm callin sap which is calling JAVA from a .exe program. The .exe program is having problems connecting to the JAVA program as there is no link?
    I did a trace as well and this is what it came up with:
    Error in program 'startrfc': ======> Exception condition "NO_BATCH" raised.
    >>>> [1] <unknown>    : EXT  <ac: 7> L DDSLOCTE01 >>> CLOSE abrfcrcv.c 429 (23850562)
      -{F0776FA3-F1A7-4662-BF7A-D1352735C394}
    *> RfcReceive
            handle = 1
             Data conversion On
    Error in program 'startrfc': <* RfcReceive [1] : returns 3:RFC_SYS_EXCEPTION
    Error in program 'startrfc': <* RfcCallReceive [1] : returns 3:RFC_SYS_EXCEPTION
    >>>> [1] <unknown>    : EXT  <ac: 8> L DDSLOCTE01 >>> FREE abrfcio.c 3517 (23850562)
      -{F0776FA3-F1A7-4662-BF7A-D1352735C394}
    Trace file opened at 20070312 164006 GMT Standard T, SAP-REL 640,0,119 RFC-VER 3 818122 MT-SL
    *> RfcClose called by external program ...
            handle = 1
    *> rfcClose called by RFC-Library in file: abrfc.c, line: 532
            handle = 1
    Trace file opened at 20070312 164006 GMT Standard T, SAP-REL 640,0,119 RFC-VER 3 818122 MT-SL
    <* rfcClose
    >* RfcClose
    Any help or ideas what it could be would be great

  • Function Module to Execute BEx Query and Save as work book.

    Hi
    I have a requirement for executing the Query after the data is loaded into the cube and save as Workbook and emailing to the user. Is there any Function module to Execute the Query and saving as Work book? . Please suggest me the way how to approach the problem.
    Thanks for your help in advance.

    Hi,
    It is possible to execute the Query and send the result as workbook vial email to the user.
    For that use should use Information Broadcaster.
    Steps:
    1. Goto information broadcaster.
    2. Choose object type as "Query"
    3.Click create new setting.
    4. Give description and choose distribution type as "Broadcast E-mail"
    5.Choose output format "XML(MS Excel)
    6.In recipient tab Give valid e-mail addres which you want to send.
    7.Save it. and give technical name
    8.Click schedule.
    9.choose "Execution with Data Change in the InfoProvider " correspondig infoprovider will be shown (check the check box)
    10. that's it. whenever data loaded in your infocube, it will be automatically executed and send to user mail.
    <removed> if u want more information let me know.
    Regards,
    Senthil Kumar.P

  • Function module to read the directory list and also run in background

    Hi All,
    I need to read few files from a folder in the server and upload the data in the file using a BDC. This process has to happen in the background as I am going to schedule the program. I had used the function module "EPS_GET_DIRECTORY_LISTING" to list the file names, it is working properly but when I schedule the program this function module does not work, the jobs gets finished in 0 secs. I am suspecting that it is not running in back ground. Can any one suggest me the function module which runs in background to read the files or an alternate method.
    Ajeetha

    Thanks for the reply.
    Sorry, this function module is working properly, why I assumed it is not working is that the background job got completed in 0 secs which made me feel that the function module is not working. Also I am subsequently copying the file to another folder and deleting it from the source folder, actually thiese two functionalities are not working in background. which added to my conclusion that all the function modules are not working in background. I am using two methods to copy and delete files, they are
    CL_GUI_FRONTEND_SERVICES=>FILE_COPY,
    CL_GUI_FRONTEND_SERVICES=>FILE_DELETE.
    as these are not working in background, now I need to replace them with a method or function module which will run in background.
    As I have mentioned earlier, my main objective is to upload the data in the file using a bdc. If I am not able to delete the file in the source folder,  then duplicate upload will happen which I have to avoid. So, if someone could help me to find a way to delete the file will be of great help to me.
    Ajeetha

  • Function Module (ENQUEUE_ES_PROG) not working in Background

    I scheduled a job which runs every 15 mins in the the background to fetch data from an external system,depending on the data volume ,the program can sometimes run for over 15 minutes.To avoid data conflict I used a function module ENQUEUE_ES_PROG on the program to first check if the job started is still running before another job gets kicked.The problem I have is the fact that this function module does not seem to work in the background but in the looks perfect in foreground. Does anyone have a clue on how to use this FM for background job?

    Hello Mochabo,
    Consider the following scenario:
    Your job is running for more than 15 minutes. Since it is running in the background, it will be executed by a work-process of type BACKGROUND. If there's only one BACKGROUND work process configured for your application server, then the second job will have to be waiting till the first one finishes and releases the background work process.
    But when you are executing this in the foreground, the DIALOG work-process does the processing. So you are not finding any problem.
    So, to my knowledge, there will be a problem when there's only one BACKGROUND work process. Please go to transaction SM50 and see how many of them are configured for the current application server.
    Also, in case there's only one BACKGROUND work-process, you will not have toworry that the second job will start before the first has finished. It simply can't. It has got to wait.
    Hope this explanation helps.
    Regards,
    Anand Mandalika.

  • Function module  to determine the credit balance or if there is an open ite

    Hi All ,
    Can anyone please let me is there any function module  to determine the credit balance orr if there is an open standing request / open standing request /paid but not yet refunded security deposit .
    Requirement :
    Purpose -This report shows a list of u201Cinactiveu201D contract accounts and the amounts to be refunded (credit balance, paid security deposit) to customers.  This report also shows any open standing requests in customersu2019 contract accounts.
    Note:  SAP does not have a concept of u201Cinactiveu201D contract accounts.  All contract accounts are active in SAP.   
    We do have customers who pay several months in advance (when they are out of town and donu2019t want to have their services disconnected). 
    Logic to retrieve the u201Cinactiveu201D accounts:
    The inactive accounts can be identified by the Move-In/Out dunning procedure. If the mov-in/out dunning procedure is not empty, that means this account has moved out and the account is inactive.
    Business Logic and Flow
    For each contract account
    Go through each installation and check if it is disconnected
         If (one is active)
    move to the next contract account
    else (all is disconnected)
         check to see if there is a credit balance or if there is an open standing request
         If (credit balance)
    {Display contract account, customer number and information, and credit balance for refund}
    If (open standing request)
    {Display contract account, customer number and information, standing request number to be closed}
    If (paid but not yet refunded security deposit)
    {Display contract account, customer number and information, current balance and security deposit amount}
    Thanks in advance
    Rahul

    Hi Rahul,
    To find out the credit balance relating to security deposits you can use BAPI_ACCOUNT_GETBALANCES. On execution of this BAPI with BP and Contract Account Number, it will return the net balance with different segments like open, due, credit and likewise security deposit amount.
    To find out if there is any open standing request standing against the customer you can use BAPI_CTRACCONTRACTACCOUNT_GOI. You have to execute this BAPI by providing BP or Contract Account number in Main Selections  table and Main and Sub Transaction of Security Deposit Request transaction in Value Selection table. This BAPI will fetch all open items with the main and sub transactions specified and display.
    Thanks
    Ganesh

  • Function Module 'Save_text' in update task of Vl01n

    Hi Friends,
    My requirement is, when i save a delivery document, the 'Material Sales text' in delivery has to be updated with custom details.
    It is good that we can code the function module 'Save_text' in update task in the exit provided for VL01n - Delivery creation right.
    At saving of delivery, we can use the set, get parameters to get the delivery document no and pass it to the Function module 'Save_text' in update task. Hope this will work.
    Correct me if i am wrong.
    Highly appreciate your valuable responses.
    Thanks,
    Jaffer Ali.S

    Hi,
    You are going in a correct method proceed. Its been good to know whether you are going correct or wrong.
    Cheers!!
    VEnk@

  • Function module to read the the idoc

    Hi abap gurus,
       I have an inbound idoc coming form a wms system .The IDOC is for goods recieved . how can I read the idoc to update the inbound delivery data in the sap system ? Is there any function module to read the data from teh inbound idoc ?

    Hi Gaurab,
    Creating a Function Module (Direct Inbound Processing)
    This step describes how to create a function module which is identified by the IDoc Interface using a new process code and called from ALE (field TBD52-FUNCNAME). Direct inbound processing using a function module (not using a workflow) always includes the ALE layer. This setting (processing with function module and ALE layer) is identified by the value 6 in the field TEDE2-EDIVRS, which is read by the function module IDOC_START_INBOUND. IDOC_START_INBOUND then calls ALE.
    Prerequisites
    You must have completed the required steps in Defining and Using a Basic Type .
    Procedure
    Choose Tools ® ABAP Workbench ® Development ® Function Builder, and create a new function module.
    Create the segments as global data in your function group. The function module should copy the application data from the segments into the corresponding application tables and modify the IDoc status accordingly. If an error occurs, the function module must set the corresponding workflow parameters for exception handling.
    Activate the function module: From the initial screen of the Function Builder select .
    In the example, create the function module IDOC_INPUT_TESTER with a global interface. The function module is called when an IDoc of type TESTER01 is received for inbound processing. You will assign an application object ("standard order") to this IDoc type and therefore maintain tables from SD. To do this, call transaction VA01 using the command CALL TRANSACTION. Please note that the intention here is not to simulate a realistic standard order, but only to illustrate how data reaches application tables from an IDoc table via segment structures (form routine READ_IDOC_TESTER) and how the function module triggers an event for exception handling (by returning suitable return variables to the ALE layer in the FORM routine RETURN_VARIABLES_FILL).
    A comprehensive example of the code for an inbound function module is provided in the ALE documentation in the SAP Library under  Example Program to Generate an IDoc. This function module, for example, also checks whether the logical message is correct and calls a (fictitious) second function module which first writes the application data and then returns the number of the generated document. In addition, status 53 is only set if the application document was posted correctly.
    Administration parameters for IDOC_INPUT_TESTER
    Application abbreviation
    V (Sales and Distribution)
    Processing type
    Normal, start immediately
    Interface for IDOC_INPUT_TESTER (global interface)
    Formal parameters
    Reference structure
    Explanation
    Import parameters
    INPUT_METHOD
    BDWFAP_PAR-INPUTMETHD
    Describes how the function module is to be processed (example: in the background)
    MASS_PROCESSING
    BDWFAP_PAR-MASS_PROC
    Mass inbound processing? (indicator)
    Export parameters
    WORKFLOW_RESULT
    BDWFAP_PAR-RESULT
    Set to 99999 if an event is to be triggered for error handling.
    APPLICATION_VARIABLE
    BDWFAP_PAR-APPL_VAR
    Variable freely available from application for workflow
    IN_UPDATE_TASK
    BDWFAP_PAR-UPDATETASK
    Asynchronous update? (indicator is not set in example)
    CALL_TRANSACTION_DONE
    BDWFAP_PAR-CALLTRANS
    Transaction called? (indicator is not set in example)
    Table
    IDOC_CONTRL
    EDIDC
    IDoc control record
    IDOC_DATA
    EDIDD
    IDoc data records
    IDOC_STATUS
    BDIDOCSTAT
    IDoc status records for ALE
    RETURN_VARIABLES
    BDWFRETVAR
    IDoc assigned to Object type method parameters.
    SERIALIZATION_INFO
    BDI_SER
    If several IDocs are to be processed in a certain sequence: this structure contains the necessary information
    Example
    FUNCTION IDOC_INPUT_TESTER.
    ""Globale Schnittstelle:
    *"       IMPORTING
    *"             VALUE(INPUT_METHOD) LIKE  BDWFAP_PAR-INPUTMETHD
    *"             VALUE(MASS_PROCESSING) LIKE  BDWFAP_PAR-MASS_PROC
    *"       EXPORTING
    *"             VALUE(WORKFLOW_RESULT) LIKE  BDWFAP_PAR-RESULT
    *"             VALUE(APPLICATION_VARIABLE) LIKE  BDWFAP_PAR-APPL_VAR
    *"             VALUE(IN_UPDATE_TASK) LIKE  BDWFAP_PAR-UPDATETASK
    *"             VALUE(CALL_TRANSACTION_DONE) LIKE  BDWFAP_PAR-CALLTRANS
    *"       TABLES
    *"              IDOC_CONTRL STRUCTURE  EDIDC OPTIONAL
    *"              IDOC_DATA STRUCTURE  EDIDD
    *"              IDOC_STATUS STRUCTURE  BDIDOCSTAT
    *"              RETURN_VARIABLES STRUCTURE  BDWFRETVAR
    *"              SERIALIZATION_INFO STRUCTURE  BDI_SER
    initialize SET/GET Parameter and internal tables
      PERFORM INITIALIZE_ORGANIZATIONAL_DATA.
    Move IDOC to internal tables of application
      PERFORM READ_IDOC_TESTER.
    call transaction Order Entry VA01
      PERFORM CALL_VA01_IDOC_ORDERS USING ERRORCODE.
    set status value
      perform write_status_record using errorcode.
    return values of function module
      PERFORM RETURN_VARIABLES_FILL USING ERRORCODE.
    ENDFUNCTION.
    FORM INITIALIZE_ORGANIZATIONAL_DATA.
    initialize SET/GET parameters
       SET PARAMETER ID 'VKO' FIELD SPACE.
       SET PARAMETER ID 'VTW' FIELD SPACE.
       SET PARAMETER ID 'SPA' FIELD SPACE.
       SET PARAMETER ID 'VKB' FIELD SPACE.
       SET PARAMETER ID 'VKG' FIELD SPACE.
    initialize internal tables
       REFRESH BDCDATA.
       CLEAR BDCDATA.
       CLEAR BELEGNUMMER.
       CLEAR ERRTAB.
       REFRESH ERRTAB.
       REFRESH XBDCMSGCOLL.
       CLEAR XBDCMSGCOLL.
    ENDFORM.                    " INITIALIZE_ORGANIZATIONAL_DATA
    FORM READ_IDOC_TESTER.
      PERFORM INITIALIZE_IDOC.
    LOOP AT IDOC_DATA
       WHERE DOCNUM = IDOC_CONTRL-DOCNUM.
        CASE IDOC_DATA-SEGNAM.
    header data
          WHEN 'E1HEAD'.
            MOVE IDOC_DATA-SDATA TO E1HEAD.
            PERFORM PROCESS_SEGMENT_E1HEAD.
    position data
          WHEN 'E1ITEM'.
            MOVE IDOC_DATA-SDATA TO E1ITEM.
            PERFORM PROCESS_SEGMENT_E1ITEM.
        ENDCASE.
    ENDLOOP.
    only when there were one or more items
      CHECK FIRST NE 'X'.
      APPEND XVBAP.                        "last one
    ENDFORM.                    " READ_IDOC_TESTER
    FORM INITIALIZE_IDOC.
      CLEAR XVBAK.
      REFRESH XVBAP.
      CLEAR XVBAP.
      POSNR = 0.
      FIRST = 'X'.
    ENDFORM.                    " INITIALIZE_IDOC
    FORM PROCESS_SEGMENT_E1HEAD.
    requested date of delivery
      WLDAT = E1HEAD-WLDAT.
    delivery date
      XVBAK-BSTDK = E1HEAD-BSTDK.
    customer number
      XVBAK-KUNNR = E1HEAD-AUGEB.
    order number
      XVBAK-BSTNK = E1HEAD-BELNR.
    division
      XVBAK-SPART = E1HEAD-SPART.
    distribution channel
      XVBAK-VTWEG = E1HEAD-VTWEG.
    sales organization
      XVBAK-VKORG = E1HEAD-VKORG.
    order type
      XVBAK-AUART = E1HEAD-AUART.
    do not fill incoterms (inco1, inco2)
    customer function
      CALL CUSTOMER-FUNCTION '001'
           EXPORTING
                PI_VBAK621           = XVBAK
           IMPORTING
                PE_VBAK621           = XVBAK
           TABLES
                PT_IDOC_DATA_RECORDS = IDOC_DATA.
    ENDFORM.                    " PROCESS_SEGMENT_E1HEAD
    FORM PROCESS_SEGMENT_E1ITEM.
    position number
      XVBAP-POSNR = XVBAP-POSNR + 1.
    amount
      XVBAP-WMENG = E1ITEM-MENGE.
    unit
      CALL FUNCTION 'ISO_TO_SAP_MEASURE_UNIT_CODE'
           EXPORTING
                ISO_CODE  = E1ITEM-BMEINH
           IMPORTING
                SAP_CODE  = XVBAP-VRKME
           EXCEPTIONS
                OTHERS    = 0.
    material number
      XVBAP-MATNR = E1ITEM-LMATNR.
    CALL CUSTOMER-FUNCTION '002'
           EXPORTING
                PI_VBAP621           = XVBAP
           IMPORTING
                PE_VBAP621           = XVBAP
           TABLES
                PT_IDOC_DATA_RECORDS = IDOC_DATA.
    APPEND XVBAP.
    ENDFORM.                    " PROCESS_SEGMENT_E1ITEM
    FORM CALL_VA01_IDOC_ORDERS USING ERRORCODE.
    call transaction first dynpro
      PERFORM DYNPRO_START.
    call transaction double-line entry
      PERFORM DYNPRO_DETAIL2.
    incoterms
      PERFORM DYNPRO_HEAD_300.
    call transaction item datas
      PERFORM DYNPRO_POSITION.
      PERFORM DYNPRO_SET USING 'BDC_OKCODE' 'SICH'.
    determine input method
      IF INPUT_METHOD IS INITIAL.
        INPUT_METHOD = 'N'.
      ENDIF.
    call transaction VA01
    CALL TRANSACTION 'VA01' USING    BDCDATA
                             MODE     INPUT_METHOD
                             UPDATE   'S'
                             MESSAGES INTO XBDCMSGCOLL.
    errorcode = SY-SUBRC.       " remember returncode for status update
    ENDFORM.                    " CALL_VA01_IDOC_ORDERS
    form write_status_record using errorcode.
    FILL IDOC_STATUS
    IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
    IF ERRORCODE = 0.
    IDOC_STATUS-STATUS = BELEG_GEBUCHT. "value 53
       GET PARAMETER ID 'AUN' FIELD BELEGNUMMER.
       IDOC_STATUS-MSGID = 'V1'.
       IDOC_STATUS-MSGNO = '311'.
       IDOC_STATUS-MSGV1 = 'Terminauftrag'.
       IDOC_STATUS-MSGV2 = BELEGNUMMER.
    ELSE.
        IDOC_STATUS-STATUS = BELEG_NICHT_GEBUCHT. "value 51
        IDOC_STATUS-MSGID = SY-MSwGID.
        IDOC_STATUS-MSGNO = SY-MSGNO.
        IDOC_STATUS-MSGV1 = SY-MSGV1.
        IDOC_STATUS-MSGV2 = SY-MSGV2.
        IDOC_STATUS-MSGV3 = SY-MSGV3.
        IDOC_STATUS-MSGV4 = SY-MSGV4.
      ENDIF.
      APPEND IDOC_STATUS.
    ENDFORM.
    FORM DYNPRO_START.
      PERFORM DYNPRO_NEW USING PROGRAMM_AUFTRAG
                               DYNPRO-EINSTIEG
                      CHANGING LAST_DYNPRO.
    ordertype
      PERFORM DYNPRO_SET USING 'VBAK-AUART' XVBAK-AUART.
    sales organization
      PERFORM DYNPRO_SET USING 'VBAK-VKORG' XVBAK-VKORG.
    Distribution channel
      PERFORM DYNPRO_SET USING 'VBAK-VTWEG' XVBAK-VTWEG.
    Division
      PERFORM DYNPRO_SET USING 'VBAK-SPART' XVBAK-SPART.
    Sales office
      PERFORM DYNPRO_SET USING 'VBAK-VKBUR' XVBAK-VKBUR.
    Sales group
      PERFORM DYNPRO_SET USING 'VBAK-VKGRP' XVBAK-VKGRP.
    ENDFORM.                    " DYNPRO_START
    FORM DYNPRO_NEW USING    PROGNAME
                             DYNPRONR
                    CHANGING LAST_DYNPRO.
    CLEAR BDCDATA.
    BDCDATA-PROGRAM = PROGNAME.
    BDCDATA-DYNPRO  = DYNPRONR.
    BDCDATA-DYNBEGIN   = 'X'.
    APPEND BDCDATA.
    LAST_DYNPRO = DYNPRONR.
    ENDFORM.                    " DYNPRO_NEW
    FORM DYNPRO_SET USING    FELDNAME
                             FELDINHALT.
      CLEAR BDCDATA.
      CHECK FELDINHALT NE SPACE.
    dynpro field name
      BDCDATA-FNAM = FELDNAME.
    contents
      BDCDATA-FVAL = FELDINHALT.
      APPEND  BDCDATA.
    ENDFORM.                    " DYNPRO_SET
    FORM DYNPRO_DETAIL2.
    okcode
    PERFORM DYNPRO_SET USING 'BDC_OKCODE' PANEL-UER2.
    fix dynpro number 4001
      PERFORM DYNPRO_NEW  USING    PROGRAMM_AUFTRAG
                                   '4001'
                          CHANGING LAST_DYNPRO.
    order party
      PERFORM DYNPRO_SET      USING 'KUAGV-KUNNR'  XVBAK-KUNNR.
    purchase order number
      PERFORM DYNPRO_SET      USING 'VBKD-BSTKD'   XVBAK-BSTNK.
    requested delivery date
      PERFORM DYNPRO_DATE_SET USING 'VBKD-BSTDK'   XVBAK-BSTDK.
    purchase order date
      PERFORM DYNPRO_DATE_SET USING 'RV45A-KETDAT' WLDAT.
    ENDFORM.                    " DYNPRO_DETAIL2
    FORM DYNPRO_DATE_SET USING    FELDNAME
                                  FELDINHALT.
      DATA: DATE TYPE D.
      CLEAR BDCDATA.
      CHECK FELDINHALT NE SPACE.
      BDCDATA-FNAM = FELDNAME.
      WRITE FELDINHALT  TO DATE.
      BDCDATA-FVAL = DATE.
      APPEND  BDCDATA.
    ENDFORM.                    " DYNPRO_DATE_SET
    FORM DYNPRO_HEAD_300.
      PERFORM DYNPRO_SET USING 'BDC_OKCODE' PANEL-KKAU.
    incoterms part 1
      IF NOT XVBAK-INCO1 IS INITIAL.
       PERFORM DYNPRO_SET USING 'VBKD-INCO1' XVBAK-INCO1.
      ENDIF.
    incoterms part 2
      IF NOT XVBAK-INCO2 IS INITIAL.
       PERFORM DYNPRO_SET USING 'VBKD-INCO2' XVBAK-INCO2.
      ENDIF.
    PERFORM DYNPRO_SET USING 'BDC_OKCODE' 'BACK'.
    ENDFORM.                    " DYNPRO_HEAD_300
    FORM DYNPRO_POSITION.
      LOOP AT XVBAP.
    dynpro item double line entry
      PERFORM DYNPRO_SET USING 'BDC_OKCODE' 'UER2'.
        IF XVBAP-POSNR = 1.
    material number
          PERFORM DYNPRO_SET      USING 'VBAP-MATNR(01)'   XVBAP-MATNR.
    order quantity
          PERFORM DYNPRO_SET      USING 'RV45A-KWMENG(01)' XVBAP-WMENG.
    desired delivery date
          PERFORM DYNPRO_DATE_SET USING 'RV45A-ETDAT(1)'  WLDAT.
    sales unit
          PERFORM DYNPRO_SET      USING 'VBAP-VRKME(1)'   XVBAP-VRKME.
        ELSE.
         PERFORM DYNPRO_SET      USING 'BDC_OKCODE'      'POAN'.
    material number
          PERFORM DYNPRO_SET      USING 'VBAP-MATNR(02)'    XVBAP-MATNR.
    order quantity
          PERFORM DYNPRO_SET      USING 'RV45A-KWMENG(02)'  XVBAP-WMENG.
    desired delivery date
          PERFORM DYNPRO_DATE_SET USING 'RV45A-ETDAT(02)'   WLDAT.
    sales unit
          PERFORM DYNPRO_SET      USING 'VBAP-VRKME(02)'    XVBAP-VRKME.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " DYNPRO_POSITION
    FORM RETURN_VARIABLES_FILL USING ERRORCODE.
    allocate IDOC numbers to Workflow output parameters
      IF MASS_PROCESSING <> SPACE.
        IF ERRORCODE = 0.
          RETURN_VARIABLES-WF_PARAM = PID.
          RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
          APPEND RETURN_VARIABLES.
          RETURN_VARIABLES-WF_PARAM = APO.
          RETURN_VARIABLES-DOC_NUMBER = BELEGNUMMER.
          APPEND RETURN_VARIABLES.
          WORKFLOW_RESULT = C_WF_RESULT_OK.
        ELSE.
          RETURN_VARIABLES-WF_PARAM = EID.
          RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
          APPEND RETURN_VARIABLES.
          WORKFLOW_RESULT = C_WF_RESULT_ERROR.
        ENDIF.
      ELSE.
        IF ERRORCODE = 0.
          RETURN_VARIABLES-WF_PARAM = APE.
          RETURN_VARIABLES-DOC_NUMBER = BELEGNUMMER.
          APPEND RETURN_VARIABLES.
          WORKFLOW_RESULT = C_WF_RESULT_OK.
        ELSE.
          WORKFLOW_RESULT = C_WF_RESULT_ERROR.
        ENDIF.
      ENDIF.
    ENDFORM.                    " RETURN_VARIABLES_FILL
    Globale Daten von IDOC_INPUT_TESTER
    TABLES: E1HEAD, E1ITEM.
    DATA: BEGIN OF BDCDATA OCCURS 500.
            INCLUDE STRUCTURE BDCDATA.
    DATA: END OF BDCDATA.
    DATA: BEGIN OF XVBAK.                 "Kopfdaten
         INCLUDE STRUCTURE VBAK621.
    DATA: END OF XVBAK.
    DATA: BEGIN OF XVBAP OCCURS 50.        "Position
           INCLUDE STRUCTURE VBAP.
    DATA:  WMENG(18) TYPE C.
    DATA:  LFDAT LIKE VBAP-ABDAT.
    DATA:  KSCHL LIKE KOMV-KSCHL.
    DATA:  KBTRG(16) TYPE C.
    DATA:  KSCHL_NETWR LIKE KOMV-KSCHL.
    DATA:  KBTRG_NETWR(16) TYPE C.
    DATA:  INCO1 LIKE VBKD-INCO1.
    DATA:  INCO2 LIKE VBKD-INCO2.
    DATA:  YANTLF(1) TYPE C.
    DATA:  PRSDT LIKE VBKD-PRSDT.
    DATA:  HPRSFD LIKE TVAP-PRSFD.
    DATA: END OF XVBAP.
    DATA: BEGIN OF DYNPRO,
          EINSTIEG          LIKE T185V-DYNNR VALUE 101,
          KKAU              LIKE T185V-DYNNR,
          UER2              LIKE T185V-DYNNR,
          KBES              LIKE T185V-DYNNR,
          ERF1              LIKE T185V-DYNNR,
          PBES              LIKE T185V-DYNNR,
          PKAU              LIKE T185V-DYNNR,
          PEIN              LIKE T185V-DYNNR,
          EID1              LIKE T185V-DYNNR,
          POPO              LIKE T185V-DYNNR,
          EIPO              LIKE T185V-DYNNR,
          KPAR              LIKE T185V-DYNNR,
          PSDE              LIKE T185V-DYNNR,
          PPAR              LIKE T185V-DYNNR,
          KDE1              LIKE T185V-DYNNR,
          KDE2              LIKE T185V-DYNNR,
          PDE1              LIKE T185V-DYNNR,
          PDE2              LIKE T185V-DYNNR,
          PKON              LIKE T185V-DYNNR,
          END OF DYNPRO.
    DATA: BEGIN OF PANEL,
          KKAU              LIKE T185V-PANEL VALUE 'KKAU',
          UER2              LIKE T185V-PANEL VALUE 'UER2',
          KBES              LIKE T185V-PANEL VALUE 'KBES',
          ERF1              LIKE T185V-PANEL VALUE 'ERF1',
          PBES              LIKE T185V-PANEL VALUE 'PBES',
          PKAU              LIKE T185V-PANEL VALUE 'PKAU',
          PEIN              LIKE T185V-PANEL VALUE 'PEIN',
          EID1              LIKE T185V-PANEL VALUE 'EID1',
          EIAN              LIKE T185V-PANEL VALUE 'EIAN',
          POPO              LIKE T185V-PANEL VALUE 'POPO',
          EIPO              LIKE T185V-PANEL VALUE 'EIPO',
          KPAR              LIKE T185V-PANEL VALUE 'KPAR',
          PSDE              LIKE T185V-PANEL VALUE 'PSDE',
          POAN              LIKE T185V-PANEL VALUE 'POAN',
          PPAR              LIKE T185V-PANEL VALUE 'PPAR',
          KDE1              LIKE T185V-PANEL VALUE 'KDE1',
          KDE2              LIKE T185V-PANEL VALUE 'KDE2',
          PDE1              LIKE T185V-PANEL VALUE 'PDE1',
          PDE2              LIKE T185V-PANEL VALUE 'PDE2',
          PKON              LIKE T185V-PANEL VALUE 'PKON',
          KOAN              LIKE T185V-PANEL VALUE 'KOAN',
          END OF PANEL.
    DATA: BEGIN OF ERRTAB OCCURS 20,
           TRANS  LIKE TSTC-TCODE,
           ARBGB  LIKE T100-ARBGB,
           CLASS(1) TYPE C,
           MSGNR LIKE T100-MSGNR,
         TEXT LIKE T100-TEXT,
           TEXT(123) TYPE C,
           MSGV1 LIKE SY-MSGV1,
           MSGV2 LIKE SY-MSGV2,
           MSGV3 LIKE SY-MSGV3,
           MSGV4 LIKE SY-MSGV4,
          END OF ERRTAB.
    *---- Hilfsfelder     -
    DATA: PROGRAMM_AUFTRAG LIKE T185V-AGIDV VALUE 'SAPMV45A'.
    DATA: LAST_DYNPRO      LIKE T185V-DYNNR,
          WLDAT            LIKE VBAK-BSTDK,
          POSNR            LIKE VBAP-POSNR,
          FIRST(1)         TYPE C VALUE 'X'.
    DATA: BEGIN OF XBDCMSGCOLL OCCURS 10.
            INCLUDE STRUCTURE BDCMSGCOLL.
    DATA: END OF XBDCMSGCOLL.
    Terminauftrag  ( Auftragsart wird fest gesetzt !)
    DATA:   BELEGNUMMER LIKE VBAK-VBELN.
    DATA:   ERRORCODE LIKE SY-SUBRC.
    Statuswerte fuer IDOC-Status
    DATA:   BELEG_NICHT_GEBUCHT LIKE TEDS1-STATUS VALUE '51'.
    DATA:   BELEG_GEBUCHT       LIKE TEDS1-STATUS VALUE '53'.
    *- Direktwerte für Return_variables -
    data:
        eid like bdwfretvar-wf_param value 'Error_IDOCs',
        pid like bdwfretvar-wf_param value 'Processed_IDOCs',
        apo like bdwfretvar-wf_param value 'Appl_Objects',
        ape like bdwfretvar-wf_param value 'Appl_Object'.
    *- Direktwerte für Workflow_Result -
    DATA: C_WF_RESULT_ERROR LIKE BDWFAP_PAR-RESULT VALUE '99999'.
    thanks
    karthik
    DATA: C_WF_RESULT_OK    LIKE BDWFAP_PAR-RESULT VALUE '0'.

  • Function module to execute a Tcode

    Hi,
    Can any one tell me how I can call a ZTcode in a function module and execute it.. Any example???

    hi tanu,
    you can do this by writing CALL TRANSACTION command in the program.
    if you want to skip the first screen and u need to call the teansaction in new screen you can do it as
    CALL TRANSACTION 'TCODE' AND SKIP FIRST SCREEN.  " wirte your transaction name u want to call in TCODE.
    thanks & Regards,
    tanmaya

  • Function module to save the data from ALV list to MS Excel file

    Hi,
    I am displaying an ALV list.
    I am assigning a pushbutton in the GUI status to save the list as a MS Excel file.
    Can you please let me know the function module to achieve this task.
    I tried 'SAP_CONVERT_TO_XLS_FORMAT'  FM but it is giving some type confict error.
    Thanks & Regards,
    Balaji.R

    ALV has this option built in, you may also find FM like [ALV_XXL_CALL|https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_all&query=alv_xxl_call&adv=false&sortby=cm_rnd_rankvalue].
    Can you elaborate a little more on your need, why adding an option that already exits?
    Regards

  • Function module  which changes the Storage Unit (SU) Block Data like LS32

    Hi,
    Is there any Function module  which changes the Storage Unit (SU) Block Data as done in  LS32.
    Thank you,
    Prashanth A.

    Hello Pablo.
    Yes we did run LT04 and it does encounter that same error message after clicking the Stock Removal button.  But eventually error msg will be removed by entering the value at the Storage Unit Type field because it directly fills in LTAP-LETYP.
    We have resolved that the function module will not really fill the desired Storage unit type therefore TO background creation is not feasible in our scenario (non-SU managed transfer to SU-managed storage type).  And I found this thread too:  http://scn.sap.com/thread/1947358
    So issue is still open but we have considered of changing the process since this is still just a new scenario for us.
    Thanks a lot for your inputs!

  • What is the Function MOdule that returns the fields in database table order

    Hello Folks
      I have a dynamic internal table with fields ( which are not in order). I want to display them in the order of which they are present in the database table? Is there any function module that returns the fields in database order?
    FAQ. Please search before posting your question.
    Edited by: Suhas Saha on Oct 10, 2011 10:19 PM

    Hi,
    You can use this BAPI.
    <b>BAPI_SALESORDER_GETLIST</b>
    Reward if useful.
    Regards,
    Vimal

  • Function Module to know the Acc doc no for a Material document.

    Dear Friends,
    What is the Function Module to know the Acc doc no for a Material document? Please help. Thanks in advance.
    Regards,
    RAMAN

    Hi Raman,
    I am not sure about your requirement,
    But i remember when i required the same like you i went to vrpma table to get the account document,
    I just did like a blind fold,
    as my company does all the billing accounts in the same month, my search criteria was blind.
    Also try with MKPF-XBLNR with the VBRK-XBLNR and get VBRK-VBELN
    from there goto BSEG.
    Thansk & regards,
    Dileep .C

Maybe you are looking for

  • I have a problem in processing the program in background

    Hi, We have cloned the T'code V_V2 and added some additional functionality and when we try to run the program in background the error is blocking the process This is because, say example i am tring to process the sales order in production systen thro

  • Burn Problem with a 4GB project: "Layer 0 Exceeds"

    First off this is not the usual Dual-Layer problem. I know all about Layers how they work and how to make them. Although the error I receive deals with DL my projects or nowhere near that size. I recently had DVDSP 4 crash on me. Ever since than its

  • N1SM v. Jumpstart

    Having read a brief spec of N1 System Manager I was wondering about a few things but most importantly ..... since N1SM seems to install the OS does it in fact manage to do all that JumpStart does? Does JumpStart still have features and facilities tha

  • Filter in Analysis for Office

    Hello, I have an Analysis workbook with a couple of crosstabs and a lot of graphs. For those I'm using filter components. When the workbook was saved the display setting (in the BEX query) of the filters (dimensions) were Key + Text. Now the users wa

  • Having trouble installing Garage Band

    Alright. I originally installed, or at least thought I did, Garage Band when I went to my System Preferences and clicked on Update Software. Garage Band was one of several Software applications that I updated at that time. However, when I went back i