Regarding BAPI output

Hi,
   In my application, after giving input "SelectedRole" in one view and clicking submit button, it calls the following method which is in the custom controller.
public void executeZbapi_Roles_Tcodes_Display_Input( )
    //@@begin executeZbapi_Roles_Tcodes_Display_Input()
     try {
          Zbapi_Roles_Tcodes_Display_Input bapiInput = new Zbapi_Roles_Tcodes_Display_Input();
          wdContext.nodeZbapi_Roles_Tcodes_Display_Input().bind(bapiInput);
          bapiInput.setRole(wdContext.currentContextElement().getSelectedRole());
                    wdContext
                         .currentZbapi_Roles_Tcodes_Display_InputElement()
                         .modelObject()
                         .execute();
                    wdContext.nodeOutput().invalidate();
               } catch (WDDynamicRFCExecuteException ce) {
                    IWDMessageManager manager = wdComponentAPI.getMessageManager();
                    manager.reportException(ce.getMessage(), false);
    //@@end
It executes a bapi and retrieves a table which is mapped to a table in another view in webdynpro.
  I am able to get the output for the corresponding input. But what the problem is when I go back to the first view and click submit again with the same input, the table contains all the values twice. Likewise how many times I am submitting, that many times its getting displayed in the table. Actually its getting added to the same table. What I needed is the table should get cleared everytime and then it should display the required output.
How can I do this??
Regards,
Kalai

Hi Bharath,
   I have done like what u said.  But still the same condition. I dint understand ur point clearly. Also I dint understand the concept of invalidating the Model Node. Can u explain me in detail??
    This is what I did.
<b>(In FirstView)</b>
wdThis
                                   .wdGetSampleModelCust0Controller()
                                   .executeZbapi_Roles_Tcodes_Display_Input();
                              wdThis.wdFirePlugToSecondView();
<b>(In Custom Controller)</b>
public void executeZbapi_Roles_Tcodes_Display_Input( )
    //@@begin executeZbapi_Roles_Tcodes_Display_Input()
     try {
          Zbapi_Roles_Tcodes_Display_Input bapiInput = new Zbapi_Roles_Tcodes_Display_Input();
          wdContext.nodeZbapi_Roles_Tcodes_Display_Input().bind(bapiInput);
          bapiInput.setRole(wdContext.currentContextElement().getSelectedRole().toUpperCase());
                    wdContext
                         .currentZbapi_Roles_Tcodes_Display_InputElement()
                         .modelObject()
                         .execute();
               } catch (WDDynamicRFCExecuteException ce) {
                    IWDMessageManager manager = wdComponentAPI.getMessageManager();
                    manager.reportException(ce.getMessage(), false);
    //@@end
<b>(In Second View)</b>
public void onActionBackToR3View(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
Zbapi_Roles_Tcodes_Display_Input bapiInput = new Zbapi_Roles_Tcodes_Display_Input();
               wdContext.nodeZbapi_Roles_Tcodes_Display_Input1().bind(bapiInput);
            wdContext.nodeZbapi_Roles_Tcodes_Display_Input1().invalidate();
          wdThis.wdFirePlugToFirstView();
Can u explain me in detail: why we have to bind the node to a new BAPI object?

Similar Messages

  • Validation on BAPI output

    Hi Experts,
          I have a BAPI with output either 1 or 0, if output of BAPI is 1 it has to navigate to one form, if output is 0 it should navigate to another form. Can any one of you please suggest me how to perform validation on BAPI output.
    Regards,
    Lakshmi

    Hi Prassana,
    You can use 'store' to load 1 or 0 from your BAPI by drawing a line with store from your BAPI output port. And use visibility condition on your form.
    On your store element, assigned your field (field @field).
    Drag two forms to your board, one on top of other, and make a visibilty condition such as: @field==1
    When you BAPI sends the value==1 to 'Store' form 01 is shown otherwise form 2 is shown.
    Regards,
    Gilson

  • Calling SAPGui depending on BAPI Output and User selection

    Hi everybody,
    can I somehow call a SAPGui (like in the transaction iView) depending on BAPI Output and the selection of a user?
    The problem is the following:
    Through an input form, a BAPI function receives an input parameter. I then get several results and want to select one of these results. With this result a predefined transaction <b>with SAPGui</b> should start.
    For example transaction MW23 with purchase order number 1234567.
    Does anybody know a solution to this?
    Thanks, Rebecca

    Hi Raju,
    as far as I know, you always need an ITS if you want to present a transaction in Portal as HTMLGUI.
    However, I now found a way how to use the transaction iView with the WINGui. Of course, the SAPGui client has to be installed locally.
    With the following URL the transaction iView can be called and the user can jump into a certain transaction with a certain parameter, in this case with the purchase order number:
    ('http://SERVER:50000/irj/servlet/prt/portal/prtroot/pcd!3a!2f!2fportal_content!2fcom.sap.pct!2ftemplates!2fiviews!2fcom.sap.portal.sap_transaction_iview?System=Q06&TCode=me22n&GuiType=WinGui&DynamicParameter=%7EOKCODE%3D%26RM06E-BSTNR%3D')(@PO_NUMBER)('&SAP_Dynp_AutoStart=true')
    Whereas
    SERVER has to be adapted,
    Q06 is a system for R/3 configured in the portal,
    TCode can be any transaction which can accept parameters,
    @PO_NUMBER is the variable from visual composer.
    Regards, Rebecca

  • Regarding BAPI Docu

    Hi,
    I want to learn BAPI,can anyone send me the documentation regarding BAPI.
    Like what is BAPI?
    use of BAPI?
    When the BAPI will be used..........
    Thanx in advance.

    Hi,
    BAPI-step by step
    http://www.sapgenie.com/abap/bapi/example.htm
    list of all bapis
    http://www.planetsap.com/LIST_ALL_BAPIs.htm
    for BAPI's
    http://www.sappoint.com/abap/bapiintro.pdf
    http://www.sappoint.com/abap/bapiprg.pdf
    http://www.sappoint.com/abap/bapiactx.pdf
    http://www.sappoint.com/abap/bapilst.pdf
    http://www.sappoint.com/abap/bapiexer.pdf
    http://service.sap.com/ale
    http://service.sap.com/bapi
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCMIDAPII/CABFAAPIINTRO.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/CABFABAPIREF/CABFABAPIPG.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCFESDE8/BCFESDE8.pdf
    http://www.planetsap.com/Bapi_main_page.htm
    http://www.topxml.com/sap/sap_idoc_xml.asp
    http://www.sapdevelopment.co.uk/
    http://www.sapdevelopment.co.uk/java/jco/bapi_jco.pdf
    Also refer to the following links..
    www.sappoint.com/abap/bapiintro.pdf
    www.sap-img.com/bapi.htm
    www.sap-img.com/abap/bapi-conventions.htm
    www.planetsap.com/Bapi_main_page.htm
    www.sapgenie.com/abap/bapi/index.htm
    Checkout !!
    http://searchsap.techtarget.com/originalContent/0,289142,sid21_gci948835,00.html
    http://techrepublic.com.com/5100-6329-1051160.html#
    http://www.sap-img.com/bapi.htm
    http://www.sap-img.com/abap/bapi-conventions.htm
    http://www.sappoint.com/abap/bapiintro.pdf
    BAPI
    http://help.sap.com/saphelp_46c/helpdata/en/9b/417f07ee2211d1ad14080009b0fb56/frameset.htm
    http://searchsap.techtarget.com/originalContent/0,289142,sid21_gci948835,00.html
    http://www.sapgenie.com/abap/bapi/example.htm
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCMIDAPII/CABFAAPIINTRO.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/CABFABAPIREF/CABFABAPIPG.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCFESDE8/BCFESDE8.pdf
    u can check the below the material also
    what is BAPI?
    BAPI stands for Business API(Application Program Interface).
    I have answered this question before..
    A BAPI is remotely enabled function module ie it can be invoked from remote programs like standalone JAVA programs, web interface etc..
    You can make your function module remotely enabled in attributes of Function module but
    A BAPI are standard SAP function modules provided by SAP for remote access. Also they are part of Businees Objest Repository(BOR).
    BAPI are RFC enabled function modules. the difference between RFc and BAPI are business objects. You create business objects and those are then registered in your BOR (Business Object Repository) which can be accessed outside the SAP system by using some other applications (Non-SAP) such as VB or JAVA. in this case u only specify the business object and its method from external system in BAPI there is no direct system call. while RFC are direct system call Some BAPIs provide basic functions and can be used for most SAP business object types. These BAPIs should be implemented the same for all business object types. Standardized BAPIs are easier to use and prevent users having to deal with a number of different BAPIs. Whenever possible, a standardized BAPI must be used in preference to an individual BAPI.
    The following standardized BAPIs are provided:
    Reading instances of SAP business objects
    GetList ( ) With the BAPI GetList you can select a range of object key values, for example, company codes and material numbers.
    The BAPI GetList() is a class method.
    GetDetail() With the BAPI GetDetail() the details of an instance of a business object type are retrieved and returned to the calling program. The instance is identified via its key. The BAPI GetDetail() is an instance method. BAPIs that can create, change or delete instances of a business object type
    The following BAPIs of the same object type have to be programmed so that they can be called several times within one transaction. For example, if, after sales order 1 has been created, a second sales order 2 is created in the same transaction, the second BAPI call must not affect the consistency of the sales order 2. After completing the transaction with a COMMIT WORK, both the orders are saved consistently in the database.
    Create( ) and CreateFromData! ( )
    The BAPIs Create() and CreateFromData() create an instance of an SAP business object type, for example, a purchase order. These BAPIs are class methods.
    Change( )
    The BAPI Change() changes an existing instance of an SAP business object type, for example, a purchase order. The BAPI Change () is an instance method.
    Delete( ) and Undelete( ) The BAPI Delete() deletes an instance of an SAP business object type from the database or sets a deletion flag.
    The BAPI Undelete() removes a deletion flag. These BAPIs are instance methods.
    Cancel ( ) Unlike the BAPI Delete(), the BAPI Cancel() cancels an instance of a business object type. The instance to be cancelled remains in the database and an additional instance is created and this is the one that is actually canceled. The Cancel() BAPI is an instance method.
    Add<subobject> ( ) and Remove<subobject> ( ) The BAPI Add<subobject> adds a subobject to an existing object inst! ance and the BAPI and Remove<subobject> removes a subobject from an object instance. These BAPIs are instance methods.
    Example Code
    U need to give the step_nr, item_nr, cond_count and cond_type so the correct conditon will be updated. If no condition exists for the given parameters, a new condition will be created.
    U can find these parameters for a particular condition type in table KONV.
    *& Form saveTransactionJOCR
    text
    --> p1 text
    <-- p2 text
    FORM saveTransactionJOCR .
    data: salesdocument like BAPIVBELN-VBELN,
    order_header_inx like bapisdh1x,
    order_header_in like bapisdh1,
    return type standard table of bapiret2 with header line,
    conditions_in type standard table of bapicond with header line,
    conditions_inx type standard table of bapicondx with header line,
    logic_switch like BAPISDLS,
    step_nr like conditions_in-cond_st_no,
    item_nr like conditions_in-itm_number,
    cond_count like conditions_in-cond_count,
    cond_type like conditions_in-cond_type.
    salesdocument = wa_order_information-VBELN.
    LOGIC_SWITCH-COND_HANDL = 'X'.
    order_header_inx-updateflag = 'U'.
    conditions
    clear conditions_in[].
    clear conditions_inx[].
    clear: step_nr,
    item_nr,
    cond_count,
    cond_type.
    step_nr = '710'.
    item_nr = '000000'.
    cond_count = '01'.
    cond_type = 'ZCP2'.
    CONDITIONS_IN-ITM_NUMBER = item_nr.
    conditions_in-cond_st_no = step_nr.
    CONDITIONS_IN-COND_COUNT = cond_count.
    CONDITIONS_IN-COND_TYPE = cond_type.
    CONDITIONS_IN-COND_VALUE = 666.
    CONDITIONS_IN-CURRENCY = 'EUR'.
    append conditions_in.
    CONDITIONS_INX-ITM_NUMBER = item_nr.
    conditions_inx-cond_st_no = step_nr.
    CONDITIONS_INX-COND_COUNT = cond_count.
    CONDITIONS_INX-COND_TYPE = cond_type.
    CONDITIONS_INX-UPDATEFLAG = 'U'.
    CONDITIONS_INX-COND_VALUE = 'X'.
    CONDITIONS_INX-CURRENCY = 'X'.
    append conditions_inx.
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
    EXPORTING
    SALESDOCUMENT = salesdocument
    ORDER_HEADER_IN = order_header_in
    ORDER_HEADER_INX = order_header_inx
    LOGIC_SWITCH = logic_switch
    TABLES
    RETURN = return
    CONDITIONS_IN = conditions_in
    CONDITIONS_INX = conditions_inx
    if return-type ne 'E'.
    commit work and wait.
    endif.
    ENDFORM. " saveTransactionJOCR
    Bdc to Bapi
    The steps to be followed are :
    1. Find out the relevant BAPI (BAPI_SALESORDER_CHANGE for VA02).
    [for VA01 use BAPI_SALESORDER_CREATEFROMDAT2]
    2. Create a Z program and call the BAPi (same as a Funtion module call).
    2. Now, if you see this BAPi, it has
    -> Importing structures.
    eg: SALESDOCUMENT: this will take the Sales order header data as input.
    -> Tables parameters:
    eg: ORDER_ITEM_IN: this will take the line item data as input.
    Note :
    Only specify fields that should be changed
    Select these fields by entering an X in the checkboxes
    Enter a U in the UPDATEFLAG field
    Always specify key fields when changing the data, including in the checkboxes
    The configuration is an exception here. If this needs to be changed, you need to complete it again fully.
    Maintain quantities and dates in the schedule line data
    Possible UPDATEFLAGS:
    U = change
    D = delete
    I = add
    Example
    1. Delete the whole order
    2. Delete order items
    3. Change the order
    4. Change the configuration
    Notes
    1. Minimum entry:
    You must enter the order number in the SALESDOCUMENT structure.
    You must always enter key fields for changes.
    You must always specify the update indicator in the ORDER_HEADER_INX.
    2. Commit control:
    The BAPI does not run a database Commit, which means that the application must trigger the Commit so that the changes are read to the database. To do this, use the BAPI_TRANSACTION_COMMIT BAPI.
    For further details... refer to the Function Module documentation for the BAPi.
    Bapi to VB(Visual Basic)
    Long back I had used the following flow structure to acheive the same.
    Report -> SM59 RFC destination -> COM4ABAP -> VB.exe
    my report uses the rfc destination to create a COM session with com4abap. com4abap calls the vb.exe and manages the flow of data between sap and vb exe.
    You need to have com4abap.exe
    If com4abap is installed you will find it in sapgui installatin directory , C:\Program Files\SAPpc\sapgui\RFCSDK\com4abap.
    else refer OSS note 419822 for installation of com4abap
    after making the settings in com4abap to point to the vb program and setting up rfc destination in sm59 to point to com4abap session , you can use the following function modules to call the vb code.
    for setting up com4abap and rfc destination please refer to the documentation for com4abap.
    Invoke NEW DCOM session
    call function 'BEGIN_COM_SESSION'
    exporting
    service_dest = service_dest "(this will be a RFC destination created in SM59)
    importing
    worker_dest = worker_dest
    exceptions
    connect_to_dcom_service_failed = 1
    connect_to_dcom_worker_failed = 2
    others = 3.
    call function 'create_com_instance' destination worker_dest
    exporting
    clsid = g_c_clsid
    typelib = g_c_typelib
    importing
    instid = g_f_oid
    exceptions
    communication_failure = 1 message g_f_msg
    system_failure = 2 message g_f_msg
    invalid_instance_id = 3
    others = 4.
    call function 'com_invoke' destination worker_dest
    exporting
    %instid = g_f_oid
    %method = 'UpdatePDF'
    sntemp = g_v_const_filent
    snsysid = sy-sysid
    snflag = 'N'
    tables
    rssaptable = g_t_pdfdetail1
    %return = g_t_pdfdetail1 "t_test
    exceptions
    communication_failure = 1 message g_f_msg
    system_failure = 2 message g_f_msg
    invalid_instance_id = 3
    others = 4.
    then close the com session , using
    FM delete_com_instance
    FM END_COM_SESSION
    Regards,
    Priyanka.

  • Regarding BAPI HRXSS_CAT_WD_RECORD

    Hi Experts,
    This is regarding BAPI HRXSS_CAT_WD_RECORD.for  this BAPI ,  I am providing inputs like this
    IV_PERNR = 90030.
    IV_ACTION  = COPY_FROM_PREVIOUS_PERIOD.
    IV_BEGDA = 09/20/2008 .
    IV_ENDDA = 09/26/2008 .
    So this BAPI has to copy the previous period(week) data to current week what I provided in the input area.But it is not returing (it is not copying previous week data).means COPY_FROM_PREVIOUS_PERIOD action is not working in BAPI.
    Is there any BAPI for meeting this requirement. I want copy the previous weeks time sheet data to week dates provided in input. This functionality is available in Tcode in cat22.
    Regards,
    Vinod

    You may use the following BAPI (actual BAPI these one) to fulfil your requirement:
    - [BAPI_CATIMESHEETRECORD_GETLIST|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=bapi_catimesheetrecord_getlist&adv=false&sortby=cm_rnd_rankvalue]
    - [BAPI_CATIMESHEETMGR_INSERT|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=bapi_catimesheetmgr_insert&adv=false&sortby=cm_rnd_rankvalue]
    Regards

  • Regarding BAPI Return Table

    Hi all,
    I am having an issues, when the user enters the correct value into an input field then i am getting the output properly. But if he enters any wrong value a message is populated into the BAPI return table. So how do I check if the BAPI return table is empty or not. If it is empty then it has to open the output table and if it is not empty it has to show the error message as an pop-up or table format.
    Please reply, points will be rewarded.
    Thanks & Regards,
    M.Ramana Murthy

    Hi Ramana,
    If you want to capture the message returning from the BAPI which you are using then do the following:
    1.> Drag the line from the BAPI return port and link it to a form or to a table.
    2.> Then go to the form/table click the UIelement and in properties of that assign the default value which you want to display. It may be a message coming out of the BAPI.Through this way you can capture the values coming out of the BAPI
    Regards,
    Nutan

  • How to export from VC a bapi output table to a PDF file

    Hello,
    How can I export a output table results from a BAPI (not BI Query) to a PDF file?
    Regards

    Hi
    There is very simple way of exporting the data to PDF. Follow the steps -
    1. Download PDF convertor on your machine.
    2. Create one button 'Convert to PDF' in your VC model.
    3. IN this button assign system command as 'Print'
    4. Save & Execute the model.
    After execution when you will click on this button, it will open normal print pop up window. Here you will find PDF convertor. Select this & Convert to PDF.
    Regards
    Sandeep

  • Regarding the output of background job in spool

    Hi Friends:
         I have a report.When I run it in foreground, it displays an alv output.
    I want to see the output when I run it in background. When I select the job & press on spool, it shows a message that no list available. Please help with the settings to see the output in spool.
    Suitable points will be rewarded.
    Regards:
    Gaurav

    Hi,
    have a look at this thread:
    Re: OO ALV in background job
    Best regards.

  • Regarding BAPI at sales order

    Dear guys,
    I have CSV file having records, which is read from local PC and has to be uploaded in R/3 screen.
    Concretely speaking, Now Records from CSV files will be displayed in Sales order screen. customer will correct the data changes in screen(if necessary for each record) and save the record to sales table.
    1-Here i want to know should i have to use BAPI or not for saving datas in sales order table.
    (Its purely ABAP programming module)
    2-if Bapi is required could you pls tell what BAPI is required to save in sales table.
    Thanks in advance.
    ambichan.

    Hi Ambichan,
    first of all: don't make changes (/ use exits / BADI) for this task. Only if you need different functionality for sales document creation itself, you might do some enhancements.
    Copy of this transaction doesn't make much sense: to much to delete. Maybe you use screen definition, but the rest you should do on your own.
    Do you need feedback from system?
    Yes: use BAPI_SALESORDER_SIMULATE to get feedback (like delivery days, availability...) and display results in own transaction.
    No: just display the values like an editor (but in corresponding fields and places of VA01).
    If you create only one order at a time, then it's also possible to use a batch input (VA01), started in error mode, to fill all fields. Then your last action is pressing enter (instead of save). Transaction will pop up, because it's not finished -> user is in correct transaction, feedback from system is available, all additional functions (like display customer / article / whatever else data) are at hand...
    Regards,
    Christian

  • Regarding bapi

    hi all,
      i am getting a flat file from application server .i have to do some validations and i am passing these values to bapi structure to create Purchase requisition(PR).but it is not creating any PR.
    i am sending my code to u pls go through  that .and tell me where i have to change it
    report   zlpr_inb_str_create
              no standard page heading
              line-size 250
              message-id zl_msg.
                      TYPES  DECLARATION                                 *
    types:begin of ty_data,
           sc_code     type t001l-lgort,    "School Code
           course      type ltext,          "Course
           stock_item  type matnr,          "Stocked Item Number
           quantity    type char5,          "Requisition Quantity
           ac_info     type char20,         "Accounting Information
           fincode     type bp_geber,       "Fund
           fkber       type fkber   ,       "Functional Area
           kostl       type kostl   ,       "Cost Center
           saknr       type saknr   ,       "G/L Account Number
           gsber       type gsber   ,       "Business Area
        end of ty_data.
    types:begin of ty_log ,
         sc_code       type t001l-lgort,     "School Code
         course        type ltext,           "Course
         stock_item    type matnr,           "Stocked Item Number
         quantity      type char5,           "Requisition Quantity
         ac_info       type char20,          "Accounting Information
         s_date        type sy-datum,        "System Date
         s_time        type sy-uzeit,        "System Time
         err_msg       type char100,         "Error Message
         end of ty_log.
    types:begin of ty_mara,
            matnr       type mara-matnr,                            "Material code
            ac_info(20) type c,
          end of ty_mara.
    types:begin of ty_lgort,
          lgort type t001l-lgort,                                   "Storage Location
          ac_info(20) type c,
          end of ty_lgort.
    types:begin of ty_fincode,
          fincode type fmfincode-fincode,                             "SAP Fund
          end of ty_fincode      .
    types:begin of ty_fkber,
          fkber type tfkb-fkber,                                     "SAP Function Area
          end of ty_fkber      .
    types:begin of ty_kostl,
          kostl type csks-kostl,                                     "SAP Cost Center
          end of ty_kostl      .
    types:begin of ty_saknr,
          saknr type ska1-saknr,                                     "SAP GL Account
          end of ty_saknr      .
    types:begin of ty_gsber,
         gsber type tgsb-gsber,                                      "SAP Business Area
         end of ty_gsber      .
                      VARIABLES DECLARATION                              *
    data: g_fincode      type  bp_geber,                              "Fund
          g_fkber        type  fkber   ,                              "Functional Area
          g_kostl        type  kostl   ,                              "Cost Center
          g_saknr        type  saknr   ,                              "G/L Account Number
          g_gsber        type  gsber   ,                              "Business Area
          g_itmcnt       type  i       ,                              "Count for item lines
          g_err          type  c       .                              "For error messages
                      INTERNAL TABLES DECLARATION                        *
    data:it_data    type standard table of ty_data with header line,
         it_dynsel  type table of dselc with header line,
         it_dynval  type table of dval,
         it_log     type standard table of ty_log,                    "Error log
         it_mara    type standard table of ty_mara,                   "Material Number
         it_lgort   type standard table of ty_lgort,                  "Storage Location
         it_fincode type standard table of ty_fincode,                "Fund
         it_fkber   type standard table of ty_fkber,                  "Functional Area
         it_kostl   type standard table of ty_kostl,                  "Cost Center
         it_saknr   type standard table of ty_saknr,                  "G/L Account Number
         it_gsber   type standard table of ty_gsber.                  "Bussiness Area
                      WORK AREA DECLARATION                              *
    data: wa_data    type ty_data,
          wa_string  type string,
          wa_log     type ty_log,                                     "Error Log
          wa_mara    type ty_mara,                                    "Material Number
          wa_lgort   type ty_lgort,                                   "Storage Location
          wa_fincode type ty_fincode,                                 "Fund
          wa_fkber   type ty_fkber,                                   "Functional Area
          wa_kostl   type ty_kostl,                                   "Cost Center
          wa_saknr   type ty_saknr,                                   "G/L Account Number
          wa_gsber   type ty_gsber,                                   "Bussiness Area
          wa_helpinf type help_info.
        INTERNAL TABLES DECLARATION FOR PASSING VALUES IN BAPI           *
    data : it_item     type standard table of bapiebanc,            "Item Data
           it_atasg    type standard table of bapiebkn,             "Account Assignment Data for Item
           it_ittxt    type standard table of bapiebantx,           "Text for Item
           it_return   type standard table of bapireturn,           "Return Messages
           g_reqstno   type bapiebanc-preq_no.                      "Purchase Requisition Number
    data : wa_bapiebanc  type bapiebanc,
           wa_bapiebkn   type bapiebkn ,
           wa_bapiebantx type bapiebantx,
           wa_return     type bapireturn.
                      CONSTANTS                                          *
    constants: c_program      type ztcca_pgmconst value 'ZLPR_INB_STR_CREATE', "program Name
               c_field1       type ztcca_pgmconst value 'Z_STR_CREATE',
               c_msg          type char41 value 'No Valid Records to Process in the file',
               c_module       type char2 value 'PR',
               c_dev_type     type zcca_dev_type value 'INT',
               c_movement     type zcca_movement value 'I',
               c_object_id    type char25  value 'PR_INB_0001',
               c_dlmtr        type c value '|',                              "For Deliminator
               c_fldname(10)  type c value 'FILEINTERN',                     "For File name FM
               c_dyflname(19) type c value 'FILENAME-FILEINTERN',            "For File name FM
               c_fname(8)     type c value 'FILENAME',                       "For file name FM
               c_prog(8)      type c value 'RSSYSTDB',                       "For file name FM
               c_chktable(10) type c value 'FILENAMECI',                     "For file name FM
               c_dynpro(4)    type c value '1000',                           "For File name FM
               c_dynprofld(6) type c value 'P_FILE',                         "For File name FM
               c_call(1)      type c value 'T',                              "For File name FM
               c_spras        type c value 'E',                              "For File name FM
               c_obj(1)       type c value 'F',                              "For File name FM
               c_pov(1)       type c value 'N',                              "For File name FM
               c_currow(1)    type c value '3',                              "For File name FM
               c_curcol(2)    type c value '35',                             "For File name FM
               c_sydyn(1)     type c value 'S',                              "For File name FM
               c_pr_type(4)   type c value 'ZUB',                            "For PR Type
               c_item_cat(1)  type c value 'U',                              "For Item Category
               c_ac_asign(1)  type c value 'K',                              "For Cost Center
               c_pur_grp(1)   type c value 'H',                              "For Purchasing Group
               c_pur_org(4)   type c value 'DCPS',                           "For Purchasing Organisation
               c_gl_ac(4)     type c value 'CABE',
               c_unit(2)      type c value  'EA',                            "For Unit Of Measure
               c_r_plant(4)   type c value '1000' ,                          "For Requesting Plant
               c_10(2)        type c value '10',
               c_3000(4)      type c value '3000',                           "For Supplying Plant
               c_90(2)        type c value '90',
               c_ok(1)        type c value 'X',
               c_i(1)         type c value 'I',
               c_eq(2)        type c value 'EQ',
               c_flag(1)      type c value 'X'   ,
               c_x(1)         type c value 'X'   ,
               c_coma(1)        type c value ','   ,
               c_00(2)        type c value '00'  ,
               c_0000(4)      type c value '0000'  ,
               c_one          type i value 1       ,
               c_98           type i value 98       .
        AT SELECTION-SCREEN                                             *
    *-- selection screen declarations
    selection-screen begin of block b_source with frame title text-008.
    parameters: p_file  type localfile .                                        "Source file name
    parameters:rb_phy   radiobutton group path user-command ucmd default 'X',   "Physical path
               rb_logic     radiobutton group path .                            "Logical path
    selection-screen end of block b_source.
        AT SELECTION-SCREEN ON  VALUE-REQUEST                           *
    at selection-screen on value-request for p_file.
    *--Get the value help for the application server .
      perform get_value_help.
        AT SELECTION-SCREEN ON  INPUT FILE                              *
    at selection-screen on p_file.
    *--Validate the physical file path of application server
      perform validate_file_path using p_file.
        START-OF-SELECTION EVENT                                        *
    start-of-selection.
    *--To get source file data from application server
      perform get_file_data.
    *-- Validate input file data
      perform validate_data.
    *-- Post STR / PR in SAP
      perform create_str.
    *--To display the processing log
    PERFORM display_log.
    *--- Display Default Application server file path on selection screen
      perform default_app_server_file.
    *&      Form  VALIDATE_FILE_PATH
          Validate physical file path for application server
    form validate_file_path using p_app_file.
      data:   l_app_fname type sldstring, "APPLICATION FILE NAME
              l_test type sldagtst.       "TEST INDICATOR
      move p_app_file to l_app_fname.
      if rb_phy = 'X'.
        if p_file ne space.
    *CHECK WHETHER FILE EXIST IN THE APPLICATION SERVER
          call function 'SLDAG_CHECK_FILE_EXISTENCE'
            exporting
              fq_file_name = l_app_fname
            importing
              exists       = l_test.
          if l_test is initial.
            message i023.   "File not found.
          endif.
        endif.
      endif.
      clear l_test.
    endform.                    " VALIDATE_FILE_PATH
    *&      Form  GET_VALUE_HELP
          Get the help for the file name
    form get_value_help .
      if rb_phy = 'X'.
        call function '/SAPDMC/LSM_F4_SERVER_FILE'
          exporting
            directory        = '.'
          importing
            serverfile       = p_file
          exceptions
            canceled_by_user = 1
            others           = 2.
        if sy-subrc <> 0.
          message i023.                        "File not found
        endif.
      elseif rb_logic = c_ok.
        clear: wa_helpinf,
               it_dynsel,
               it_dynval.
        refresh: it_dynsel,
                 it_dynval.
    Set the parameters before invoking the FM
    for browsing the logical filename
        wa_helpinf-call         = c_call.
        wa_helpinf-object       = c_obj.
        wa_helpinf-program      = c_prog.
        wa_helpinf-dynpro       = c_dynpro.
        wa_helpinf-tabname      = c_fname.
        wa_helpinf-fieldname    = c_fldname.
        wa_helpinf-spras        = sy-langu.
        wa_helpinf-title        = sy-title.
        wa_helpinf-dynprofld    = c_dynprofld.
        wa_helpinf-checktable   = c_chktable.
        wa_helpinf-checkfield   = c_fldname.
        wa_helpinf-report       = sy-cprog.
        wa_helpinf-pov          = c_pov.
        wa_helpinf-curow        = c_currow.
        wa_helpinf-cucol        = c_curcol.
        wa_helpinf-sy_dyn       = c_sydyn.
        wa_helpinf-dynpprog     = sy-cprog.
        it_dynsel-fldname   = c_fldname.
        it_dynsel-dyfldname = c_dyflname.
        append it_dynsel.
    Call the FM to display the help for the logical filenames
        call function 'HELP_START'
          exporting
            help_infos   = wa_helpinf
          tables
            dynpselect   = it_dynsel
            dynpvaluetab = it_dynval.
      endif.
    endform.                    " GET_VALUE_HELP
    *&      Form  get_file_data
          text
    form get_file_data .
    *--Open the file and move data into table it_data
      open dataset p_file for input in text mode encoding default.
      if ( sy-subrc ne 0 ).
        message e002 with c_msg.
      endif.
      while sy-subrc = 0.
        read dataset p_file into wa_string.
        if sy-subrc = 0.
    split the string into table structure
          split wa_string at '|' into: wa_data-sc_code               "School Code
                                       wa_data-course                "Course
                                       wa_data-stock_item            "Stock Item Number
                                       wa_data-quantity              "Quantity
                                       wa_data-ac_info.              "Accounting Information
    Convert Stock Item number ( Material number )
          call function 'CONVERSION_EXIT_MATN1_INPUT'
            exporting
              input        = wa_data-stock_item                     "Stock Item Number
            importing
              output       = wa_data-stock_item                     "Stock Item Number
            exceptions
              length_error = 1
              others       = 2.
          if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          endif.
    Get SAP fields from accounting information string
          wa_data-gsber   = wa_data-ac_info+12(4).                       " validate to sap bussiness area
          concatenate  wa_data-ac_info+1(3) c_00   into wa_data-fincode. "validate to Sap fund
          concatenate  wa_data-ac_info4(4) c_00 wa_data-ac_info8(4) c_0000
                                                   into wa_data-fkber.    "Validate Functional Area
          concatenate  wa_data-ac_info+12(4) c_00  into wa_data-kostl.    "Validate Cost Center
          concatenate  wa_data-ac_info+16(4) c_00  into wa_data-saknr.    "validate to Sap GL Account
    *-- Convert Cost center into internal format
          call function 'CONVERSION_EXIT_ALPHA_INPUT'
            exporting
              input  = wa_data-kostl
            importing
              output = wa_data-kostl.
    *-- Convert G/L Account into internal format
          call function 'CONVERSION_EXIT_ALPHA_INPUT'
            exporting
              input  = wa_data-saknr
            importing
              output = wa_data-saknr.
          append wa_data to it_data.
        endif.
      endwhile.
      close dataset p_file.
      if ( sy-subrc ne 0 ).
        message e005.
      endif.
      sort it_data ascending   by sc_code .
    endform.                    " GET_FILE_DATA
    *&      Form  validate_data                                            *
          text                                                           *
    form validate_data .
    *-- If input file contains data, create STR in SAP
      if ( it_data[] is initial ).
    Error message
      message e002.
      endif.
    Extract material data for validation
      select matnr                                                   "Material Number
             from mara
             into table it_mara
             for all entries in it_data
             where matnr = it_data-stock_item.
    Extract Storage location data for validation
      select lgort                                                   "Storage Location
             from t001l
             into table it_lgort
             for all entries in it_data
             where werks =    c_3000 and
                   lgort = it_data-sc_code.
    Extract SAP Fund IDs
      select fincode                                                 "Fund
             from  fmfincode
             into table  it_fincode
             for all entries in it_data
             where  fikrs = c_pur_org
               and  fincode = it_data-fincode.
    Extract SAP Function Area
      select fkber                                                   "Functional Area
             from  tfkb
             into table    it_fkber
             for all entries in it_data
             where fkber = it_data-fkber.
    Extract SAP Cost Center
      select kostl                                                   "Cost Center
             from csks
             into table it_kostl
             for all entries in it_data
             where kokrs =  c_pur_org
             and kostl =  it_data-kostl
             and datbi >= sy-datum
             and datab <= sy-datum.
    Extract SAP G/L Account
      select saknr                                                   "G/L Account Number
             from ska1
             into table   it_saknr
             for all entries in it_data
             where ktopl =  c_gl_ac
               and saknr =  it_data-saknr.
    Extract SAP Business Area
      select gsber                                                   "Bussiness Area
             from tgsb
             into  table    it_gsber
             for all entries in it_data
             where gsber = it_data-gsber.
    Validate uploaded material and storage location data
      sort   it_mara    by matnr.                                    "Material Number
      sort   it_lgort   by lgort.                                    "Storage Location
      sort   it_fincode by fincode.                                  "Fund
      sort   it_fkber   by fkber.                                    "Functional Area
      sort   it_kostl   by kostl.                                    "Cost Center
      sort   it_saknr   by saknr.                                    "G/L Account Number
      sort   it_gsber   by gsber.                                    "Bussiness Area
      loop at it_data into wa_data.
    Validate Material number
        read table it_mara into wa_mara with key matnr = wa_data-stock_item
                                            binary search.
        if sy-subrc ne 0.
          perform update_error_log using wa_data
                                         text-001.
        endif.
    Validate Storage location ( School Code )
        read table it_lgort into wa_lgort with key lgort = wa_data-sc_code.
        if sy-subrc ne 0.
          perform update_error_log using wa_data
                                         text-002.
        endif.
    Validate  Sap fund
        read table it_fincode into wa_fincode with key  fincode = it_data-fincode
                                      binary search.
        if sy-subrc ne 0.
          perform update_error_log using wa_data
                                         text-003.
        endif.
    Validate  Functional Area
        read table   it_fkber into wa_fkber with key fkber = it_data-fkber
                                        binary search.
        if sy-subrc ne 0.
          perform update_error_log using wa_data
                                         text-004.
        endif.
    Validate  Cost Center
        read table it_kostl into wa_kostl with key kostl = it_data-kostl
                                        binary search.
        if sy-subrc ne 0.
          perform update_error_log using wa_data
                                         text-005.
        endif.
    Validate G/L Account Number
        read table   it_saknr into wa_saknr with key saknr = it_data-saknr
                                        binary search.
        if sy-subrc ne 0.
          perform update_error_log using wa_data
                                         text-006.
        endif.
    Validate to Bussiness  Area
        read table    it_gsber  into wa_gsber with key gsber = it_data-gsber
                                        binary search.
        if sy-subrc ne 0.
          perform update_error_log using wa_data
                                         text-007.
        endif.
      endloop.
    endform.                    " VALIDATE_DATA
    *&      Form  REQUISITION_CREATE
          text
    -->  p1        text
    <--  p2        text
    form requisition_create .
      if c_flag ne c_x.
        call function 'BAPI_REQUISITION_CREATE'
    exporting
        SKIP_ITEMS_WITH_ERROR                =
       automatic_source                        =    c_x
         importing
           number                              =    g_reqstno
          tables
           requisition_items                   =    it_item
           requisition_account_assignment      =    it_atasg
           requisition_item_text               =    it_ittxt
           REQUISITION_LIMITS                =
           REQUISITION_CONTRACT_LIMITS       =
           REQUISITION_SERVICES              =
           REQUISITION_SRV_ACCASS_VALUES     =
           return                              =    it_return.
           REQUISITION_SERVICES_TEXT         =
           REQUISITION_ADDRDELIVERY          =
           EXTENSIONIN                       =
        if g_reqstno is not initial.
          call function 'BAPI_TRANSACTION_COMMIT'
           exporting
             wait   =     c_x
      IMPORTING
        RETURN        =
        endif.
        read table it_return into wa_return with key type = 'E'.
        if sy-subrc eq 0.
          write: / wa_return-message.
        else.
          write: / g_reqstno.
        endif.
      endif.
    endform.                    " REQUISITION_CREATE
    *&      Form  display_log
          text
    WRITE: text-011,p_file.
    LOOP AT it_log INTO wa_log.
       WRITE : /  wa_log-sc_code, wa_log-stock_item, wa_log-quantity, sy-datum, sy-uzeit, wa_log-err_msg.
    ENDLOOP.
    *ENDFORM.                    " DISPLAY_LOG
    *&      Form  UPDATE_ERROR_LOG
          text
         -->P_WA_DATA  text
         -->P_TEXT_001  text
    To display Error Message
    form update_error_log  using    p_data     type  ty_data
                                    p_errmsg.
      clear : wa_log.
    *CONCATENATE wa_log-sc_code wa_log-course wa_log-stock_item   wa_log-quantity   wa_log-ac_info into g_err SEPARATED BY c_coma.
      wa_log-sc_code       = p_data-sc_code.                        "School Code
      wa_log-course        = p_data-course.                         "Course
      wa_log-stock_item    = p_data-stock_item.                     "Stock Item Number
      wa_log-quantity      = p_data-quantity.                       "Quantity
      wa_log-ac_info       = p_data-ac_info.                        "Account Information
      wa_log-err_msg       = p_errmsg.                                 "Error Message
      concatenate wa_log-sc_code wa_log-course wa_log-stock_item   wa_log-quantity
                                      wa_log-ac_info into g_err separated by c_coma.
      append wa_log to it_log.
    endform.                    " UPDATE_ERROR_LOG
    *&      Form  CREATE_STR
          text
    -->  p1        text
    <--  p2        text
    form create_str .
      sort it_data by sc_code.
      loop at it_data into wa_data.
        clear : wa_bapiebanc, wa_bapiebkn, wa_bapiebantx.
        at new sc_code.
          refresh : it_item,it_atasg,it_ittxt.
          clear   : g_itmcnt.
        endat.
    *-- Count of Item lines per school code
        g_itmcnt = g_itmcnt + c_one.
        wa_bapiebanc-doc_type    = c_pr_type.                  "purchase requisition documentation type
        wa_bapiebanc-item_cat    = c_item_cat.                 "ITEM CATEGORY
        wa_bapiebanc-acctasscat  = c_ac_asign.                 "Account Assignment Category
        wa_bapiebanc-material    = wa_data-stock_item.         "Material number
        wa_bapiebanc-suppl_plnt  = c_3000.                     "supplying plant
        wa_bapiebanc-pur_group   = c_pur_grp.                  "purchase Group
        wa_bapiebanc-purch_org   = c_pur_org.                  "Purchase Organisation
        wa_bapiebanc-unit        = c_unit.                     "Unit of measure
        wa_bapiebanc-plant       = c_r_plant.                 "receiving plant
        wa_bapiebanc-deliv_date  = sy-datum + 7.               "Delivary date
        append wa_bapiebanc to it_item.
        wa_bapiebkn-fund      =  it_data-fincode.              "SAP Fund
        wa_bapiebkn-func_area =  it_data-fkber.                "Functional Area
        wa_bapiebkn-bus_area  =  it_data-gsber .               "Business Area
        wa_bapiebkn-cost_ctr  =  it_data-kostl.                "Cost Center
        wa_bapiebkn-g_l_acct  =  it_data-saknr .               "G/L Account
        append wa_bapiebkn to   it_atasg .
        wa_bapiebantx-text_line =  wa_data-course.
        append wa_bapiebantx to it_ittxt.
    *-- If item line count per school code is 98, call BAPI to create STR/PR
        if ( g_itmcnt = c_98 ).
          perform requisition_create.
          refresh : it_item,it_atasg,it_ittxt.
          clear   : g_itmcnt.
          continue.
        endif.
    *-- At end of school code, call BAPI to create STR/PR
        at end of sc_code.
          perform requisition_create.
        endat.
      endloop.
    endform.                    " CREATE_STR
    *&      Form  DEFAULT_APP_SERVER_FILE
          text
    -->  p1        text
    <--  p2        text
    form default_app_server_file .
      call function 'ZCCA_DEFAULT_APP_SERVER_FILE'
        exporting
         module               = c_module
         dev_type             = c_dev_type
         movement             = c_movement
          object_id            = c_object_id
      FILE_EXTENSION       = 'TXT'
       importing
         serverfile           = p_file .
      concatenate p_file c_object_id '_' sy-datum sy-uzeit into
                                                          p_file.
    endform.                    " DEFAULT_APP_SERVER_FILE

    wa_bapiebanc-doc_type = c_pr_type. "purchase requisition documentation type
    wa_bapiebanc-item_cat = c_item_cat. "ITEM CATEGORY
    wa_bapiebanc-acctasscat = c_ac_asign. "Account Assignment Category
    wa_bapiebanc-material = wa_data-stock_item. "Material number
    wa_bapiebanc-suppl_plnt = c_3000. "supplying plant
    wa_bapiebanc-pur_group = c_pur_grp. "purchase Group
    wa_bapiebanc-purch_org = c_pur_org. "Purchase Organisation
    wa_bapiebanc-unit = c_unit. "Unit of measure
    wa_bapiebanc-plant = c_r_plant. "receiving plant
    wa_bapiebanc-deliv_date = sy-datum + 7. "Delivary date
    ***************************************************8
    here pass wa_bapiebanc-CREATE_IND= '1'.
    append wa_bapiebanc to it_item.
    note
    Short Text
         Creation Indicator (Purchase Requisition/Schedule Lines)
    Definition
         Shows whether the purchase requisition or delivery schedule line was
         created manually or automatically (e.g. as a result of the requirements
         planning process).
         In the case of delivery schedules created under scheduling agreements,
         if schedule lines with different creation indicators are consolidated to
         form a release schedule line, the creation indicator remains "blank".

  • Regarding ALV output  to Excel file download

    Hi all,
    i had a requirement when downloading the ALV output to the Excel file it should ask for the password.if the user enters the password then this pass word shuld be assigned to the  Excel file that was downloaded.
    Can i know how this can be implemented

    Hi,
    Using EXCEL_OLE_STANDARD_DAT you can specify the PASSWORD & PASSWORD OPTION.
    Regards,
    Sharat

  • Problem regarding BAPI call from a webdynpro applications

    Hi,
      We are trying to call a BAPI in R/3 system from a webdynpro application through the standard method. But we are getting some problems in JCO settings. We already wasted so much time in solving those problems. Is there anyway where i can access BAPI from Webdynpro application.
    Rgrds,
    Anna

    Hello Anna,
      You can do it by using SAP Java Connector API's in the implementation of the Webdynpro application. You can refer to the sample programs for JCO at http://service.sap.com/connectors and download the latest version of SAP JCo in that install those files as per the installation document in the downloaded zip. The downloaded zip contains information about JCo APIs and sample programs.
    Hope this will solve your problem.
    Best Regards,
    Srinivas.

  • Regarding Printing output of SAPSCRIPT Program using Transaction IW22

    Hi All,
    I am having a issue with sending <b>SAP Script output to printer</b>, We are not able to print the output.
    Transaction code we are making use to see the print preview is <b>IW22</b>.
    When we are pressing <b>Print/Fax</b> button in IW22 it is generating spool but when we close the SAP connection it is not getting printed in Printer.
    Can anybody solve this issue.
    Thanks in advance.
    Thanks & Regards,
    Rayeezuddin.

    Hi all,
    Yes i checked <b>Print Immediately</b> & <b>generate spool request</b> options and i deselected <b>Delete spool</b> option, Still i am not able to get the print & though i am able to generate spool & view print preview.
    Please try to solve my issue.
    If any further information required i am ready to provide.
    Thanks & Regards,
    Rayeez.

  • Regarding BAPI "BAPI_FUNCLOC_CHANGE" error

    Hi All,
    I have a requirement to update IFLOT table with new 3 custom fields which i have appened in the include CI_IFLOT.
    I have copied standard BAPI "BAPI_FUNCLOC_CHANGE" and created custom Function Module "Y_BAPI_FUNCLOC_CHANGE".
    Now when I activated the same, i got one error like "Type "ILOX_T_IFLOS" is unknown". I am not getting exactly why this error comes out, please tell me how to remove this error who have already worked on this.
    Thanks,
    Jay.

    hello,
    when you copied BAPI it did not copy global objects. Open BAPI via se37 choose attribute tab strip and double click on Program name SAPL( your BAPI's Function group name) you will find it on the right bottom corner and compare include in this program with the standard BAPI's program. Include missing data and you've got the solution.
    P.s. required structure is in top include-> type pool ILOX.
    best regards,
    dez_

  • Regarding BAPI for F-32

    Hi All,
    Can anybody Tell me Available Bapi for F-32( Clear Customer).
    Thanks in Advance,
    Jana

    Hi,
        Welcome To SDN!!.
    Please try one the below bapi.
    BAPI_ACC_PYMNTBLK_UPDATE_POST
    BAPI_ACC_BILLING_POST
    check this links:
    1) Re: BAPI for FB05
    2) Re: F-32 : Clearing Open Items
    Regards
    Kiran Sure

Maybe you are looking for

  • Repair Disk Permissions: is it a safe operation ?

    Hello, I'm preparing for the 101 course and, reading about the Verify/Repair disk permissions utility, I wanted to test it on my mac. I launched the verification on it and I see "lot" of unexpected entries (see below): Verifying permissions for “Maci

  • VS 2013 crashes when trying to check-in code

    Hi, We have the following issue. We are using TFS online with VS 2013. We were fine for a few months and then suddenly developers started having issues when trying to check-in their code. VS would fail and restart each time they try to check-in.  The

  • Using Imac intel based as wireless router?

    Can you use your imac as a wireless router? If anyone knows,email me.

  • How to Format Line in UML

    Hi All, Please see the screenshot below, I insert an association line between Student class and Classroom class, I want to change the line style. Such as begin arrow type or dash line. I set them via Format Shape TaskPane. But no working. Why? If my

  • ESS portal request approval thru blackberry

    Hi, I have a requirement of sending a request for approval on Blackberry as soon as a requisition is raised from ESS. The requisitions are Z-development and connected to a workflow which triggers once the requisition is raised. I want a approval requ