BAPI to change Purchase requisition

Hi
I want to change pruchase requsition EBAN- AFNAM ( requested by feild in PR line item ) . Is there any BAP to do so .
I beleive we annot do so by using BAPI_REQUISITION_CHANGE ?

Hi,
Are you referring to BAPI_PR_CHANGE?, Please refer SAP Note 325947.
Why don't you try MASS?
Regards
Shailesh

Similar Messages

  • BADI in ME52N Change Purchase Requisition

    Dear All,
      I am working on ME52N (Change Purchase Requisition). I got the ME_PROCESS_REQ_CUST  BADIu2019s  in ME52N. I need to initialize the Purchase Requisition Number in ME52N Screen before ME52N screen is displayed.
    Can any suggest where shoul I clear the Parameter id(BAN).
    Regard,
    V.S.Naidu.

    Hi,
    Refer:
    * BAPI to change the PR details
        CALL FUNCTION 'BAPI_REQUISITION_CHANGE'
          EXPORTING
            number                = v_banfn            "<--PR Number
          TABLES
            requisition_items_old = it_old_detail      "<--pass in old PR details
            requisition_items_new = it_new_detail      "<--pass in new PR details
            return                = it_return_change.  "<--return table
    *   "read for error message while changing details for PR
        READ TABLE it_return_change INTO wa_return_change WITH KEY type = 'E'.
        IF sy-subrc = 0.
          "check for ERROR
        ENDIF.
    Hope this helps you.
    Regards,
    Tarun

  • Change Purchase Requisition Document Type when item category is D

    Hi experts,
    i have problem, when i put servis number in to the servis line i havent change Purchase Requisition Document Type. Account
    Assignment Category is K and Item Category is D. It is standard of Purchase Requisition? When i set that i can change document type when item category is D.
    When i putting only material i can change Purchase Requisition Document.
    Thx for your answer.
    Laco

    Hi,
    One thing please note that once you select the document type and draft the PR and save the PR, you will  get the doc number.
    Once you get the document number you cannot change the PR document type .
    The reason is document type is linked with number range so it cannot be changed because different seriers of document number is assined to differentdocument type. 
    And moreover document type is linked with the screen settings also. So I would request you to check the settings for each doc. type

  • BAPI to reject purchase requisition

    Dear All,
    Iu2019m looking forward a BAPI to reject purchase requisition. I found below BAPIs for purchase requisition but I couldn't  find any BAPI to reject requisition? I wonder whether a BAPI exists to reject purchase requisition or not. Thanks in advance.
    - BAPI_REQUISITION_RELEASE
    - BAPI_REQUISITION_RELEASE_GEN
    - BAPI_REQUISITION_RESET_RELEASE
    - BAPI_REQUISITION_RESET_REL_GEN
    - BAPI_REQUISITION_CHANGE
    - BAPI_REQUISITION_CREATE
    - BAPI_REQUISITION_DELETE
    - BAPI_REQUISITION_GETDETAIL
    - BAPI_REQUISITION_GETITEMS
    - BAPI_REQUISITION_GETITEMSREL
    - BAPI_REQUISITION_GETRELINFO

    aarioglu,
    I am facing to the same problem.
    Did you solve it?
    Thanks in advance.
    Felipe Fernandes

  • Change Purchase Requisition Price after assigned to Quotation

    Hello.
    I created purchase requisition and assigned to Quotation.
    It if possible change purchase requisition price when is already assigned to Quotation?
    The item price is display and don't let me apply changes.
    Regards,
    Hector.

    Hello.
    I did not converted the Purchase Requsition in Purchase Order.
    I just running a Test Script, and after assigned a Quotation, the vendor sent me some price changes.
    When I call the requisition, the system don't let me change any price.
    I believe there is a good reason for that, but I need to read it.
    If anyone knows any documentation available, please let me know.

  • Error in Bapi : Change Purchase Requisition

    Dear All,
    We have requirement where we need to update the Purchase Requisition Quanity.
    For this purpose, I am using Bapi  '/AFS/CHANGE_AFS_PR_DATA'.
    In this I want to change Sheduled Qty. (AFS Grid Qty.), but I m getting error like
    "Line item 0010 : different quantities in item  and schedule line". (Sy-subrc = 3)
    Can any one help me out with this.
    Thanks in advance.
    Regards ,
    Vishal.

    Hi,
    Refer:
    * BAPI to change the PR details
        CALL FUNCTION 'BAPI_REQUISITION_CHANGE'
          EXPORTING
            number                = v_banfn            "<--PR Number
          TABLES
            requisition_items_old = it_old_detail      "<--pass in old PR details
            requisition_items_new = it_new_detail      "<--pass in new PR details
            return                = it_return_change.  "<--return table
    *   "read for error message while changing details for PR
        READ TABLE it_return_change INTO wa_return_change WITH KEY type = 'E'.
        IF sy-subrc = 0.
          "check for ERROR
        ENDIF.
    Hope this helps you.
    Regards,
    Tarun

  • BAPI to create Purchase Requisition

    Hi Experts,
    I´m looking for a BAPI to create a Purchase Requisition (Tx ME51)
    Hope you can help me!!
    Regards,
    MC.

    Hello,
    Check this.
      call function 'BAPI_REQUISITION_CREATE'
           exporting
                skip_items_with_error          = 'X'
           importing
                number                         = h_banfn
           tables
                requisition_items              = req_item
                requisition_account_assignment = req_acct
                requisition_item_text          = req_text
                return                         = return
           exceptions
                others                         = 0.
    Vasanth

  • Changing purchase requisition with processing status B

    How can I restrict purchase requisition changes with processing status B regardless release indicator. Rel 4.7

    Hi Mitra,
    You will find your answer here.
    MRP controller for PR document type
    Do let me know if it helped, as I might have to explore this option for an upcoming requirement.
    Thanks
    Shailesh

  • Change Purchase Requisition

    I'm trying to change the Purchase Requisition data, so, as a first test, I'm trying to invoke the change method but actually not changing a thing.
    I'm getting an error '80040e21' when I call the BapiChange.
    Does anybody knows what might be the problem?
    The code follows below:
    <%
      Dim oBAPI
      Dim objRequisitionItemsOld
      Dim objRequisitionItemsNew
      Dim objRequisitionAccountOld
      Dim objRequisitionAccountNew
      Dim objRequisitionTextOld
      Dim objRequisitionTextNew
      Dim objReturnChange
      ' get detail objects
      Dim sNum
      Dim objsRequisitionAccountAs
      Dim objReturnGetDetail
      Set objRequisitionItemsOld = Nothing
      Set objRequisitionItemsNew = Nothing
      Set objRequisitionAccountOld = Nothing
      Set objRequisitionAccountNew = Nothing
      Set objRequisitionTextOld = Nothing
      Set objRequisitionTextNew = Nothing
      Set objReturnChange = Nothing
      Set objsRequisitionAccountAs = Nothing
      Set objReturnGetDetail = Nothing
      sNum = "0000000001"
      ' Connect to business object PurchaseRequisition
      Set oBAPI  = CreateObject("SAP.PurchaseRequisition.1")
      oBAPI.Destination = "DCOM-DESTINATION"
      oBAPI.InitKeys(sNum)
      oBAPI.BapiGetDetail objRequisitionItemsOld, ,"X", , objsRequisitionAccountAs, objRequisitionTextOld, , , , objReturnGetDetail
      Set objRequisitionItemsNew = objRequisitionItemsOld
      Set objRequisitionAccountNew = objRequisitionAccountOld
      Set objRequisitionTextNew = objRequisitionTextOld
      oBapi.BapiChange objRequisitionItemsOld, objRequisitionItemsNew, objRequisitionAccountOld, objRequisitionAccountNew, objRequisitionTextOld, objRequisitionTextNew, objReturnChange
    %>

    Hi Leonardo,
    I never used <whatever language this is>, but I see a difference in parameter definition of function modules BAPI_REQUISITION_GETDETAIL and BAPI_REQUISITION_CHANGE.
    In FM ...getdetail table REQUISITION_ITEMS is of structure  BAPIEBAN (120 fields), in FM ...change table REQUISITION_ITEMS_OLD is of structure BAPIEBANV (34 fields).
    Maybe there is an automatic conversion - maybe you have to define two different sets of variables and convert result of FM ...getdetail yourself for input in FM ...change.
    Regards,
    Christian

  • BAPI to create Purchase Requisition for selective BOM Material

    Dear Experts,
    I need ur help, Actually I am developing a module Pool prg to create Purchase Requisition for selective Bom Material .
    Actually, standard T.Code (ME21N) create PR for a multiple BOM Materia lwhich are used to create a prepared material. But my requirement is PR should be generate for selective BOM material .
    Multiple BOM Material is used to prepared a complete Material .
    I have checked a particular BOM Material, for this matrial Purchase Requisition should be genrate.
    Please suggest me the related code and Bapi which helps me .
    Thanks & Regards,
    Swapnika

    Hi
    you can Use BAPI   BAPI_REQUISITION_CREATE
    Hope Its  help You.
    Regards
    Ajit

  • Problems with event when changing Purchase Requisition. (BO:BUS2009)

    Hi experts,
    I have a doubt with this. When i erase a position in the Purchase Requisition (ME52N), the event SIGNIFICANTLYCHANGED of BUS2009 is raised.
    When I try to modify the  Purchase Requisition not erasign the position but changing the Material group the event is not raised. Can i customize the system to define that changing the Material group is a significantly change for my system? If not, can i raise another event when this happens?
    Thanks!!
    Artur.

    Hi,
    Simply create a custom event called CHANGED in the BO.
    Create a entry for this event in SWEC tcode. Select the radio button on change.
    This should do the job.
    Note : This event will be raised for any kind of changes in this purchase requisition.
    Regards,
    Raj

  • BAPI / FM for Purchase Requisition Change

    Hello All,
    I need to add items to the existing requisition. I tried <b>BAPI_REQUISITION_CHANGE / ME_UPDATE_REQUISITION / BAPI_PR_CHANGE / FMFG_MM_REQ_CHANGE</b>, but none of them seem to be working fine for me. Anybody worked on this task or any other thoughts?
    Thanks,
    Chandni

    BAPI_REQUISITION_CHANGE has table parameters REQUISITION_ITEMS_OLD, REQUISITION_ITEMS_NEW , REQUISITION_ACCOUNT_OLD, REQUISITION_ACCOUNT_NEW, REQUISITION_TEXT_OLD, REQUISITION_TEXT_NEW. But, there is no indicator field in these old or new structures that you are creating a new line item.
    In BAPI_REQUISITION_CREATE, there is a field to block requisition (BAPIEBANC-REQ_BLOCKED) , but in BAPI_REQUISITION_CHANGE the structure BAPIEBANV does not have a field to block or unblock a req. however, this is taken care by BAPI_PR_CHANGE.
    <b>My concern is how add new line items to the existing requisition?</b>

  • BAPI to change purchase order to put deletion flag

    Hello Guru's,
            We are about to archive data & for that we need that according to date range all open purchase order ,open purchase requsitions & open RFQ should be marked for deletion.
    Is there some BAPI to do so.Please guide.

    *DELETING FLAG *
    REPORT ZMMR_DELETEPO NO STANDARD PAGE HEADING MESSAGE-ID zisb.
    tables : zvtls_sap.
    *C-- Types Declarations
    TYPES : BEGIN OF tp_flatfile_vtls,
            ebeln(10),
            ebelp type ekpo-ebelp,
            END OF tp_flatfile_vtls.
    *=====================================================================
                      INTERNAL TABLES DECLARATION
    *=====================================================================
    DATA:  t_flatfile_vtls TYPE tp_flatfile_vtls OCCURS 0 WITH HEADER LINE.
    data : begin of t_sapdata occurs 0,
           po like zvtls_sap-posap,
           item like zvtls_sap-itemsap,
           end of t_sapdata.
    data : begin of t_flatfile_vtls1 occurs 0,
           po(10),
           item like zvtls_sap-itemsap,
           end of t_flatfile_vtls1.
    data : begin of t_update occurs 0,
           mandt like zvtls_sap-mandt,
           povtls like zvtls_sap-povtls,
           itemvtls like zvtls_sap-itemvtls,
           posap like zvtls_sap-posap,
           itemsap like zvtls_sap-itemsap,
           aedat like zvtls_sap-aedat,
           paedt like zvtls_sap-paedt,
           loekz like zvtls_sap-loekz,
           end of t_update.
    data : begin of t_poheader occurs 0,
           po like zvtls_sap-posap,
           end of t_poheader.
    data : begin of t_poitem occurs 0,
           po like zvtls_sap-posap,
           item like zvtls_sap-itemsap,
           end of t_poitem.
    DATA : BEGIN OF T_MESSAGE OCCURS 0,
           MSGTY,
           MSGID(2),
           MSGNO(3),
           MSGTX(100),
           PO like zvtls_sap-povtls,
           item like zvtls_sap-itemvtls,
           END OF T_MESSAGE.
    DATA : BEGIN OF t_bapi_poheader OCCURS 0.
            INCLUDE STRUCTURE bapimepoheader.
    DATA : END OF t_bapi_poheader.
    DATA : BEGIN OF t_bapi_poheaderx OCCURS 0.
            INCLUDE STRUCTURE bapimepoheaderx.
    DATA : END OF t_bapi_poheaderx.
    DATA : BEGIN OF t_bapi_poitem OCCURS 0.
            INCLUDE STRUCTURE bapimepoitem.
    DATA : END OF t_bapi_poitem.
    DATA : BEGIN OF t_bapi_poitemx OCCURS 0.
            INCLUDE STRUCTURE bapimepoitemx.
    DATA : END OF t_bapi_poitemx.
    DATA : BEGIN OF t_bapireturn OCCURS 0.
            INCLUDE STRUCTURE bapiret2.
    DATA : END OF t_bapireturn.
    *=====================================================================
                      V A R I A B L E S
    *=====================================================================
    DATA: w_success(6)  TYPE n,
          w_bklas like t023-bklas,
          w_curryear(4),
          w_begda like sy-datum,
          w_endda like sy-datum,
          w_begyr(4),
          w_endyr(4),
          w_currmon(2),
          w_assetclass like ankt-anlkl,
          w_price type p,
          w_recordsap type i,
          w_povtls(10),
          w_count type i.
    DATA:  w_filepath TYPE rlgrap-filename,
           w_rc TYPE sy-subrc,
           w_sscrfields_ucomm1   TYPE sscrfields-ucomm,
           w_file1 TYPE string,
           w_file2 TYPE FILENAME-FILEINTERN.
    *=====================================================================
                      C O N S T A N T S
    *=====================================================================
    CONSTANTS: c_x              TYPE  c         VALUE 'X',
               c_hyp            TYPE  c         VALUE '-',
               c_err            TYPE  bdc_mart  VALUE 'E'.
    CONSTANTS:  c_slash(1)            TYPE c VALUE '/',
                c_hash(1)             TYPE c VALUE '#',
                c_pipe                TYPE c VALUE '|',
                c_1                   TYPE i VALUE 1,
                c_zero                TYPE n VALUE '0',
                c_rg1(3)              TYPE c VALUE 'rg1',
                c_gr3(3)              TYPE c VALUE 'GR3',
                c_gr2(3)              TYPE c VALUE 'GR2',
                c_e(1)                TYPE c VALUE 'E',
                c_filepath(8)         TYPE c VALUE '/interf/',
                c_filetype(10)        TYPE c VALUE 'ASC'.
    CONSTANTS : c_bapimepoheaderx   TYPE x030l-tabname
                                   VALUE 'bapimepoheaderx',
               c_bapimepoitem      TYPE  x030l-tabname
                                   VALUE 'bapimepoitem',
               c_bapimepoaccount   TYPE  x030l-tabname
                                   VALUE 'bapimepoaccount',
               c_t_bapi_poheader(15)        TYPE c
                                            VALUE 't_bapi_poheader',
               c_t_bapi_poitem(13)          TYPE c
                                            VALUE 't_bapi_poitem',
               c_t_bapi_poitemx(14)         TYPE c
                                            VALUE 't_bapi_poitemx',
               c_t_bapi_poheaderx(16)       TYPE c
                                            VALUE 't_bapi_poheaderx'.
    CLASS cl_abap_char_utilities DEFINITION LOAD.
    CONSTANTS:con_tab  TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
    *======================================================================
                           SELECTION SCREEN
    *======================================================================
    SELECTION-SCREEN BEGIN OF BLOCK inputpath WITH FRAME TITLE text-001.
    SELECTION-SCREEN : BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
    PARAMETERS : p_fore RADIOBUTTON GROUP rg1
                        USER-COMMAND pc,
                 p_back RADIOBUTTON GROUP rg1 DEFAULT 'X'.
    SELECTION-SCREEN : END OF BLOCK blk2.
    SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-003.
    PARAMETERS :  p_file1 LIKE rlgrap-filename OBLIGATORY MODIF ID gr2.
    PARAMETERS :  p_afile1 LIKE rlgrap-filename OBLIGATORY MODIF ID gr3.
    SELECTION-SCREEN : END OF BLOCK blk1.
    SELECTION-SCREEN END OF BLOCK inputpath.
    *C-- Initialization Event
    INITIALIZATION.
      CLEAR w_filepath.
      CONCATENATE c_filepath sy-sysid c_slash sy-mandt c_slash INTO
      w_filepath.
      CONDENSE w_filepath NO-GAPS.
      p_file1 = text-008.
      p_afile1 = text-009.
    *======================================================================
                           SELECTION SCREEN EVENTS
    *======================================================================
    *C-- Selection Screen Output
    AT SELECTION-SCREEN OUTPUT.
      IF p_fore = c_x.
        w_sscrfields_ucomm1 = space.
      ELSE.
        w_sscrfields_ucomm1 = c_rg1.
      ENDIF.
      LOOP AT SCREEN.
    *C--Modify selection screen if presentation
    *C--or application server radio button is chosen
        IF w_sscrfields_ucomm1 = space.
          IF screen-group1 = c_gr3.
            screen-active = c_zero.
          ENDIF.
        ELSE.
          IF screen-group1 = c_gr2.
            screen-active = c_zero.
          ENDIF.
        ENDIF.
        if screen-name = 'P_AFILE1'.
          screen-input = 0.
        ENDIF.
        MODIFY SCREEN.
      ENDLOOP.
    *C-- Selection Screen VALUE-REQUEST FOR File path
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file1.
      IF p_fore EQ c_x.
        CALL FUNCTION 'F4_FILENAME'
          EXPORTING
            program_name  = syst-cprog
            dynpro_number = syst-dynnr
          IMPORTING
            file_name     = p_file1.
      ENDIF.
    *C-- At Start of the Selection Process
    START-OF-SELECTION.
      IF p_fore EQ c_x.
        w_file1 = p_file1.
      ELSE.
        w_file2 = p_afile1.
      ENDIF.
      IF p_fore EQ c_x. " Presentaion Server
    *C--Validations for the input files
        PERFORM validate_pre_file USING p_file1.
    *C-- Load the contents of the input file into the internal table
        PERFORM upload_file TABLES t_flatfile_vtls
                            USING w_file1
                            CHANGING w_rc.
        IF w_rc <> 0.
          MESSAGE s006 DISPLAY LIKE c_e.
        ENDIF.
      ELSE. " Application Server
    *C--Validations for the input files
        PERFORM validate_app_file USING  w_file2.
    *C-- Load the contents of the input file into the internal table
        PERFORM upload_file_app TABLES t_flatfile_vtls
                                USING w_file2
                                CHANGING w_rc.
      ENDIF.
      loop at t_flatfile_vtls.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = t_flatfile_vtls-ebeln
          IMPORTING
            output = t_flatfile_vtls1-po.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = t_flatfile_vtls-ebelp
          IMPORTING
            output = t_flatfile_vtls1-item.
        append t_flatfile_vtls1.
        clear t_flatfile_vtls1.
      endloop.
      perform get_podata.
      loop at t_poheader.
        perform move_to_bapi.
        perform call_bapi.
      endloop.
      PERFORM STORE_MESSAGES TABLES T_MESSAGE.
    *&      Form  validate_pre_file
        Routine to validate presentation server file path.
         -->fp_name  text
    FORM validate_pre_file USING fp_name TYPE rlgrap-filename.
      DATA : l_result,
             l_filename TYPE string.
      l_filename = fp_name.
      CLEAR l_result.
      CALL METHOD cl_gui_frontend_services=>file_exist
        EXPORTING
          file                 = l_filename
        RECEIVING
          result               = l_result
        EXCEPTIONS
          cntl_error           = 1
          error_no_gui         = 2
          wrong_parameter      = 3
          not_supported_by_gui = 4
          OTHERS               = 5.
      IF sy-subrc <> 0.
        MESSAGE s007 DISPLAY LIKE c_e.
        LEAVE LIST-PROCESSING.
      ELSEIF l_result IS INITIAL.
        MESSAGE s008 DISPLAY LIKE c_e.
        LEAVE LIST-PROCESSING.
      ENDIF.
    ENDFORM.                    " validate_pre_file_hdr
    *&      Form  validate_app_file
          text - Checks if the path entered and filename is correct
    FORM validate_app_file USING  fp_file  TYPE FILENAME-FILEINTERN.
      data : l_fname(60).
      CALL FUNCTION 'FILE_GET_NAME'
        EXPORTING
          LOGICAL_FILENAME = FP_FILE
          OPERATING_SYSTEM = SY-OPSYS
        IMPORTING
          FILE_NAME        = L_FNAME
        EXCEPTIONS
          FILE_NOT_FOUND   = 1
          OTHERS           = 2.
      IF SY-SUBRC = '0'.
        OPEN DATASET  L_FNAME FOR INPUT IN TEXT MODE ENCODING DEFAULT.
        IF sy-subrc NE 0.
          MESSAGE s007 DISPLAY LIKE c_e.
        ELSE.
          CLOSE DATASET l_fname.
        ENDIF.
      ENDIF.
    ENDFORM.                    " validate_app_file
    *&      Form  upload_file
          Routine to upload data from file to tables.
         -->P_fp_flatfile
         -->P_fp_file
         <--P_fp_rc
    FORM  upload_file TABLES   fp_flatfile
                      USING    fp_file TYPE string
                      CHANGING fp_rc TYPE sy-subrc.
      IF fp_flatfile[] IS INITIAL.
        CALL FUNCTION 'GUI_UPLOAD'
          EXPORTING
            filename                = fp_file
            filetype                = c_filetype
            has_field_separator     = c_x
          TABLES
            data_tab                = fp_flatfile
          EXCEPTIONS
            file_open_error         = 1
            file_read_error         = 2
            no_batch                = 3
            gui_refuse_filetransfer = 4
            invalid_type            = 5
            no_authority            = 6
            unknown_error           = 7
            bad_data_format         = 8
            header_not_allowed      = 9
            separator_not_allowed   = 10
            header_too_long         = 11
            unknown_dp_error        = 12
            access_denied           = 13
            dp_out_of_memory        = 14
            disk_full               = 15
            dp_timeout              = 16
            OTHERS                  = 17.
        MOVE sy-subrc TO fp_rc.
      ENDIF.
    ENDFORM.  " upload_file
    *&      Form  upload_file_app
          text
         -->FP_FLATFILEtext
         -->FP_FILE    text
         -->FP_RC      text
    FORM  upload_file_app TABLES   fp_flatfile
                          USING    fp_file TYPE FILENAME-FILEINTERN
    CHANGING fp_rc TYPE sy-subrc.
      DATA: l_string TYPE tedata-data.
      DATA: wa_data_file TYPE tp_flatfile_vtls,
            l_wllength TYPE i,
            FNAME(60).
      CALL FUNCTION 'FILE_GET_NAME'
        EXPORTING
          LOGICAL_FILENAME = FP_FILE
          OPERATING_SYSTEM = SY-OPSYS
        IMPORTING
          FILE_NAME        = FNAME
        EXCEPTIONS
          FILE_NOT_FOUND   = 1
          OTHERS           = 2.
      IF SY-SUBRC = 0.
        OPEN DATASET  FNAME FOR INPUT IN TEXT MODE ENCODING DEFAULT.
        IF sy-subrc NE 0.
    *C-- commented by Bikash
         MESSAGE s107(yaero_ps) DISPLAY LIKE c_e.
          message e008.
        ELSE.
          DO.
            CLEAR: l_string.
            READ DATASET  FNAME INTO l_string LENGTH l_wllength.
            IF sy-subrc NE 0.
              EXIT.
            ELSE.
              SPLIT l_string AT con_tab INTO   wa_data_file-ebeln
                                               wa_data_file-ebelp.
              APPEND wa_data_file TO fp_flatfile.
            ENDIF.
          ENDDO.
          CLOSE DATASET  FNAME.
        ENDIF.
      ENDIF.
    ENDFORM.  " upload_file_app
    *&      Form  get_podata
          text
    form get_podata.
      select *
      into table t_update
      from zvtls_sap
      for all entries in t_flatfile_vtls1
       where itemvtls = t_flatfile_vtls1-item
      and povtls = t_flatfile_vtls1-po.
      sort t_update by posap itemsap.
      loop at t_update.
        at new posap.
          t_poheader-po = t_update-posap.
          append t_poheader.
          clear t_poheader.
        endat.
        t_poitem-po = t_update-posap.
        t_poitem-item = t_update-itemsap.
        append t_poitem.
        clear t_poitem.
        t_update-paedt = sy-datum.
        t_update-loekz = 'X'.
        modify t_update.
      endloop.
      modify zvtls_sap from table t_update.
    endform.                    "get_podata
    *&      Form  move_to_bapi
          text
    form move_to_bapi.
      t_bapi_poheader-po_number = t_poheader-po.
      CLEAR t_bapi_poheaderx.
      PERFORM fill_check_structure USING c_bapimepoheaderx
                                         c_t_bapi_poheader
                                         c_t_bapi_poheaderx
                                         c_x.
      refresh : t_bapi_poitem,t_bapi_poitemx.
      loop at t_poitem where po = t_poheader-po.
        clear t_bapi_poitem.
        t_bapi_poitem-po_item = t_poitem-item.
        t_bapi_poitem-delete_ind = 'X'.
        CLEAR t_bapi_poitemx.
        PERFORM fill_check_structure USING c_bapimepoitem
                                           c_t_bapi_poitem
                                           c_t_bapi_poitemx
                                           c_x.
        t_bapi_poitemx-po_item = t_poitem-item.
        t_bapi_poitemx-po_itemx = c_x.
        APPEND t_bapi_poitem.
        APPEND t_bapi_poitemx.
        clear t_bapi_poitem.
        clear t_bapi_poitemx.
      endloop.
    endform.                    "move_to_bapi
    *&      Form  call_bapi
          This form Routine is used to commit the data records
    FORM call_bapi .
      DATA : l_msgty      TYPE c,
             l_msgid(2)   TYPE c,
             l_msgno(3)   TYPE c,
             l_msgtx(100) TYPE c,
             l_errflag    TYPE c.
      CLEAR: t_bapireturn.
      REFRESH: t_bapireturn.
      *CALL FUNCTION 'BAPI_PO_CHANGE'*
        EXPORTING
          PURCHASEORDER = T_POHEADER-PO
          POHEADER      = T_BAPI_POHEADER
          POHEADERX     = T_BAPI_POHEADERX
        TABLES
          RETURN        = T_BAPIRETURN
          POITEM        = T_BAPI_POITEM
          POITEMX       = T_BAPI_POITEMX.
      READ TABLE t_bapireturn WITH KEY type = c_err TRANSPORTING NO FIELDS.
      IF sy-subrc NE 0.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            wait = c_x.
      ENDIF.
    *C-- Write messages
      WRITE: / 'PO Number', t_poheader-po.
      clear : t_update,w_povtls.
      read table t_update with key posap = t_poheader-po.
      w_povtls = t_update-povtls.
      CLEAR l_errflag.
      LOOP AT t_bapireturn.
        CLEAR: l_msgty, l_msgid, l_msgno, l_msgtx.
        l_msgty = t_bapireturn-type.
        l_msgid = t_bapireturn-id.
        l_msgno = t_bapireturn-number.
        l_msgtx = t_bapireturn-message.
        WRITE: / l_msgty, l_msgid, l_msgno, l_msgtx.
        if l_msgtx cs t_poheader-po.
          w_count = w_count + 1.
          loop at t_update.
            if sy-tabix = w_count.
              t_message-item = t_update-itemvtls.
            endif.
          endloop.
        endif.
        t_message-msgty = l_msgty.
        t_message-msgid = l_msgid.
        t_message-msgno = l_msgno.
        t_message-msgtx = l_msgtx.
        t_message-po = w_povtls.
        append t_message.
        clear t_message.
        IF l_msgty EQ c_err.
          l_errflag = c_x.
        ENDIF.    " l_msgty EQ 'E'
      ENDLOOP.
      ULINE.
      IF l_errflag NE c_x.
        w_success = w_success + 1.
      ENDIF.    " l_errflag NE C_X
    endform.                    "call_bapi
    *&      Form  fill_check_structure
          This form Routine will check whether the specified structure
          exist/active
    FORM fill_check_structure  USING    fp_tabname TYPE any
                                        fp_orgtabname TYPE any
                                        fp_chktabname TYPE any
                                        fp_check TYPE c.
      FIELD-SYMBOLS : <fs_chk>, <fs_org>.
      DATA:    l_char1(61)  TYPE c,
               l_char2(61)  TYPE c.
      DATA:    BEGIN OF tl_nametab OCCURS 60.
              INCLUDE STRUCTURE x031l.
      DATA:    END OF tl_nametab.
      REFRESH tl_nametab.
      CALL FUNCTION 'RFC_GET_NAMETAB'
        EXPORTING
          tabname          = fp_tabname
        TABLES
          nametab          = tl_nametab
        EXCEPTIONS
          table_not_active = 1
          OTHERS           = 2.
      IF sy-subrc <> 0.
        CLEAR tl_nametab.
      ENDIF.
      LOOP AT tl_nametab.
        CLEAR: l_char1, l_char2.
        CONCATENATE fp_chktabname c_hyp tl_nametab-fieldname INTO l_char1.
        ASSIGN (l_char1) TO <fs_chk>.
        CONCATENATE fp_orgtabname c_hyp tl_nametab-fieldname INTO l_char2.
        ASSIGN (l_char2) TO <fs_org>.
        IF <fs_org> IS NOT INITIAL.
          <fs_chk> = fp_check.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " fill_check_structure
    *&      Form  STORE_MESSAGES
          text
         -->FP_MESSAGEStext
    FORM STORE_MESSAGES TABLES FP_MESSAGES STRUCTURE T_MESSAGE.
      DATA: wl_output_data LIKE t_MESSAGE.
      DATA: l_catstr TYPE string.
      DATA: l_fieldvalue TYPE string.
      DATA: l_index TYPE i VALUE 1.
      DATA: L_FNAME(60).
      FIELD-SYMBOLS <fs>.
      CLEAR l_catstr.
      CALL FUNCTION 'FILE_GET_NAME'
        EXPORTING
          LOGICAL_FILENAME = '/USR/SAP/VTLS/POCHANGE/LOG'
          OPERATING_SYSTEM = SY-OPSYS
        IMPORTING
          FILE_NAME        = L_FNAME
        EXCEPTIONS
          FILE_NOT_FOUND   = 1
          OTHERS           = 2.
      IF SY-SUBRC = '0'.
        IF fp_messages[] IS NOT INITIAL.
          OPEN DATASET L_FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
          IF sy-subrc NE 0.
            LEAVE LIST-PROCESSING.
          ELSE.
            LOOP AT fp_messages INTO wl_output_data.
              DO.
               ASSIGN COMPONENT l_index OF STRUCTURE wl_output_data TO <fs>.
                IF sy-subrc <> 0.
                  EXIT.
                ENDIF.
                MOVE <fs> TO l_fieldvalue.
                IF l_catstr IS NOT INITIAL.
                  CONCATENATE l_catstr l_fieldvalue INTO l_catstr SEPARATED
                  BY con_tab.
                ELSE.
                  MOVE l_fieldvalue TO l_catstr.
                ENDIF.
                l_index = l_index + c_1.
                CLEAR l_fieldvalue.
                CLEAR <fs>.
              ENDDO.
              l_index = c_1.
              TRANSFER l_catstr TO L_FNAME .
              CLEAR wl_output_data.
              CLEAR l_catstr.
            ENDLOOP.
            CLOSE  DATASET L_FNAME.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDFORM.                    "STORE_MESSAGES

  • LSMW issue using BAPI for changing Purchase Order G/L Account

    Wonder if anyone can help as I'm tearing my hair out!!
    Have used LSMW lots of times using the transaction recorder, but tried using a BAPI as we have a mass update to do of G/L Accounts for Purchase Orders and it seems the tidiest and most efficient way to do it.
    Got my LSMW project working as a test by changing the Short Text on a purchase order, this works fine.  However, when I add the Account Assignment details in (Structure E1BPMEPOACCOUNT and E1BPMEACCOUNTX) everything seems to run fine, the IDOC posts and gives message 'Document xxx changed'.  Yet when I look into the order it hasn't actually changed the G/L.
    If I go into the purchase order in change mode in another session and run the LSMW again it recognises the purchase order is locked so it seems to be doing everything right, just not updating the G/L Account field.  Anyone got any ideas ? It updated the short text fine so I'm sure everything is set up OK but for some reason it ignores the G/L that I upload.  Anything relating to the Account Assignment (Unloading Point, GR, Cost Center) just gets ignored if I try and upload a change.
    I seem to be so close it seems a shame not to be able to get it sorted !!!
    Thanks,

    Helen Smith wrote:
    HI Praveen,
    >
    > Thank you very much for your response.  I tested the BAPI as per yor instructions and the return message comes back 'Eng & other PO xxxx changed' so it seems to indicate a success message again (like the LSMW does) but the actual data doesn't update.
    >
    > I thought I'd found it as I searched OSS and found note  0001382965 which seemed exactly my problem.  I imported it and applied it but yet I still get the same issue - LSMW runs, says app doc posted and purchase order has been saved but no Account Assignment field will update.
    >
    > So it seems as if it's the BAPI not doing what it should - so I'm considering logging with SAPNET just to see if they can help as getting desperate with this one now! Felt sure I had it sorted when I found that note!
    >
    > Thanks
    >
    > Helen
    >
    > ** I should add I also ran the test above altering something in the item detail (the short text) - and that worked and updated.  So it still seems to point to the Account Assignment part of the BAPI not updating.
    >
    > Edited by: Helen Smith on Nov 2, 2010 4:35 PM
    Hi Helen,
    Just wondering whether you have found solution to your issue.
    We also encounter the same issue and have implemented the note without any positive result.
    Please share if you found the solution.
    Thank you.
    Abraham

  • Problem with bapi to create purchase requisition

    I got a requirement that to upload details of procurement into Z table with a temporary PR. Could u please suggest the procedure or bapi to upload datainto Z table.
    Regards

    Hi all
    For above requirement i am suppose to develop a FM which upload the data from front end to DB. Forthat I am taking following steps is it ok or not suggest me.
    1.call function module bapi_pr_create
    2.fill local structure with bapi structure if PR number is created.
    3.update data into Z table
    Regards

Maybe you are looking for

  • Display icons in dvt:scheduledGantt taskbar

    Hi, Jdev 11.1.1.2.0. I want to display an icon within the taskbar of scheduledGantt. My VO has a attribute "icon1" with the value "/css/icons/exception.png". This attribute is assigned to the "icon1"-property of the gantt (in the Task section). Thoug

  • Document version in CV01N

    Hello experts, Is it possible control the value of the field Document Version in CV01N. SAP maintain the last value used in this transaction, I would like to have this filed empty in every CV01N execution. Is it possible?? Thanks in advance. Laura

  • Alpha channel movie issues?

    I am starting this thread to see if there's a pattern here. I sell QT timers on my web site and someone e-mailed me today to say that the timer doesn't work in Keynote 4...the timers have a transparent background and for some reason, because of that,

  • TNS:protocol adapter error - Password problem?

    When orainst Custom Install asked me for a password for the TNS listener, I typed one in. Now I find I cannot connect with the listener. If the password is the problem I cannot find out where the password has to be given in the listener configuration

  • How to back up a Windows partition created in Boot Camp in Lion.

    Hello. I have Lion installed and I already had Windows 7 installed aswell. I used boot camp. Boot Camp booted Win. 7 just fine. Then, yesterday, I tried to boot into Win. 7 and all that apeared was a Black screen with a dash in the upper left hand co