Get PO from vendor master data

Hi,
Those any body knows a BAPI or FM that would get the PO that was created in the IDOC from vendor master data?
Please help...
thank you...
regards,
mae

Hi Mae,
hope this may be of some help.
REPORT zpo_bapi_purchord_tej.
DATA DECLARATIONS *
TYPE-POOLS slis.
TYPES: BEGIN OF ty_table,
v_legacy(8),
vendor TYPE bapimepoheader-vendor,
purch_org TYPE bapimepoheader-purch_org,
pur_group TYPE bapimepoheader-pur_group,
material TYPE bapimepoitem-material,
quantity(13),
delivery_date TYPE bapimeposchedule-delivery_date,
net_price(23),
plant TYPE bapimepoitem-plant,
END OF ty_table.
TYPES: BEGIN OF ty_alv,
v_legs(8),
success(10),
v_legf(8),
END OF ty_alv.
TYPES: BEGIN OF ty_alv1,
v_legf1(8),
v_msg(500),
END OF ty_alv1.
*-----Work area declarations.
DATA: x_table TYPE ty_table,
x_header TYPE bapimepoheader,
x_headerx TYPE bapimepoheaderx,
x_item TYPE bapimepoitem,
x_itemx TYPE bapimepoitemx,
x_sched TYPE bapimeposchedule,
x_schedx TYPE bapimeposchedulx,
x_commatable(255),
x_alv TYPE ty_alv,
x_alv1 TYPE ty_alv1,
x_alv2 TYPE ty_alv1.
*-----Internal table declarations.
DATA: it_table TYPE TABLE OF ty_table,
it_commatable LIKE TABLE OF x_commatable,
it_item TYPE TABLE OF bapimepoitem,
it_itemx TYPE TABLE OF bapimepoitemx,
it_sched TYPE TABLE OF bapimeposchedule,
it_schedx TYPE TABLE OF bapimeposchedulx,
it_alv TYPE TABLE OF ty_alv,
it_alv1 TYPE TABLE OF ty_alv1,
it_alv2 TYPE TABLE OF ty_alv1.
DATA: po_number TYPE bapimepoheader-po_number,
x_return TYPE bapiret2,
it_return TYPE TABLE OF bapiret2,
v_file TYPE string,
v_temp(8),
v_succsount TYPE i VALUE 0,
v_failcount TYPE i VALUE 0,
v_total TYPE i.
DATA: v_temp1(5) TYPE n VALUE 0.
DATA: x_event TYPE slis_t_event,
x_fieldcat TYPE slis_t_fieldcat_alv,
x_list_header TYPE slis_t_listheader,
x_event1 LIKE LINE OF x_event,
x_layout1 TYPE slis_layout_alv,
x_variant1 TYPE disvariant,
x_repid2 LIKE sy-repid.
DATA : it_fieldcat TYPE TABLE OF slis_t_fieldcat_alv.
SELECTION-SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK v_b1 WITH FRAME.
*-----To fetch the flat file.
PARAMETERS: p_file TYPE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK v_b1.
AT SELECTION-SCREEN *
AT SELECTION-SCREEN.
IF p_file IS INITIAL.
MESSAGE text-001 TYPE 'E'.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
*-----To use F4 help to find file path.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = p_file.
v_file = p_file.
START-OF-SELECTION *
START-OF-SELECTION.
PERFORM gui_upload.
LOOP AT it_table INTO x_table.
PERFORM header_details.
v_temp = x_table-v_legacy.
LOOP AT it_table INTO x_table WHERE v_legacy = v_temp.
PERFORM lineitem.
PERFORM schedule.
ENDLOOP.
DELETE it_table WHERE v_legacy = v_temp.
PERFORM bapicall.
MOVE po_number TO x_alv-success.
APPEND x_alv TO it_alv.
CLEAR x_alv.
*-----To clear the item details in internal table after the operation for a header.
REFRESH: it_item,
it_itemx,
it_sched,
it_schedx.
CLEAR: v_temp1.
ENDLOOP.
v_total = v_succsount + v_failcount.
PERFORM display_alv.
FORM GUI_UPLOAD *
FORM gui_upload .
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = v_file
filetype = 'ASC'
TABLES
data_tab = it_commatable
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17
IF sy-subrc = 0.
*-----To fetch the comma seperated flat file into an internal table.
LOOP AT it_commatable INTO x_commatable.
IF x_commatable IS NOT INITIAL.
SPLIT x_commatable AT ',' INTO
x_table-v_legacy
x_table-vendor
x_table-purch_org
x_table-pur_group
x_table-material
x_table-quantity
x_table-delivery_date
x_table-net_price
x_table-plant.
APPEND x_table TO it_table.
ENDIF.
CLEAR x_table.
ENDLOOP.
ENDIF.
ENDFORM. " gui_upload
FORM HEADER_DETAILS *
FORM header_details .
MOVE 'NB' TO x_header-doc_type.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = x_table-vendor
IMPORTING
output = x_table-vendor
MOVE x_table-vendor TO x_header-vendor.
MOVE x_table-purch_org TO x_header-purch_org.
MOVE x_table-pur_group TO x_header-pur_group.
x_headerx-doc_type = 'X'.
x_headerx-vendor = 'X'.
x_headerx-purch_org = 'X'.
x_headerx-pur_group = 'X'.
ENDFORM. " header_details
FORM LINEITEM *
FORM lineitem .
v_temp1 = v_temp1 + 10.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_temp1
IMPORTING
output = v_temp1.
MOVE v_temp1 TO x_item-po_item.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = x_table-material
IMPORTING
output = x_table-material.
MOVE x_table-material TO x_item-material.
MOVE x_table-quantity TO x_item-quantity.
MOVE x_table-net_price TO x_item-net_price.
MOVE x_table-plant TO x_item-plant.
x_itemx-po_item = v_temp1.
x_itemx-material = 'X'.
x_itemx-quantity = 'X'.
x_itemx-net_price = 'X'.
x_itemx-plant = 'X'.
APPEND x_item TO it_item.
APPEND x_itemx TO it_itemx.
CLEAR: x_item, x_itemx.
ENDFORM. " lineitem1
FORM SCHEDULE *
FORM schedule .
MOVE x_table-delivery_date TO x_sched-delivery_date.
MOVE v_temp1 TO x_sched-po_item.
x_schedx-delivery_date = 'X'.
x_schedx-po_item = v_temp1.
APPEND x_sched TO it_sched.
APPEND x_schedx TO it_schedx.
CLEAR: x_sched, x_schedx.
ENDFORM. " schedule
FORM BAPICALL *
FORM bapicall .
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = x_header
poheaderx = x_headerx
IMPORTING
exppurchaseorder = po_number
TABLES
return = it_return
poitem = it_item
poitemx = it_itemx
poschedule = it_sched
poschedulex = it_schedx.
IF po_number IS NOT INITIAL.
v_succsount = v_succsount + 1.
MOVE x_table-v_legacy TO x_alv-v_legs.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ELSE.
v_failcount = v_failcount + 1.
MOVE x_table-v_legacy TO x_alv-v_legf.
MOVE x_table-v_legacy TO x_alv1-v_legf1.
LOOP AT it_return INTO x_return.
IF x_alv1-v_msg IS INITIAL.
MOVE x_return-message TO x_alv1-v_msg.
ELSE.
CONCATENATE x_alv1-v_msg x_return-message INTO x_alv1-v_msg SEPARATED BY space.
ENDIF.
ENDLOOP.
APPEND x_alv1 TO it_alv1.
CLEAR x_alv1.
ENDIF.
ENDFORM. " bapicall
FORM DISPLAY_ALV *
FORM display_alv .
PERFORM x_list_header.
PERFORM build_fieldcat CHANGING x_fieldcat.
x_repid2 = sy-repid.
x_event1-name = 'TOP_OF_PAGE'.
x_event1-form = 'TOP_OF_PAGE'.
APPEND x_event1 TO x_event.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = x_repid2
is_layout = x_layout1
it_fieldcat = x_fieldcat
i_callback_user_command = 'USER_COMMAND'
i_callback_top_of_page = 'TOP_OF_PAGE'
i_save = 'A'
is_variant = x_variant1
it_events = x_event
TABLES
t_outtab = it_alv
EXCEPTIONS
program_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.
ENDFORM. " display_master_data
FORM USER_COMMAND *
FORM user_command USING ucomm LIKE sy-ucomm selfield
TYPE slis_selfield.
READ TABLE it_alv INTO x_alv INDEX selfield-tabindex.
CLEAR : x_alv2,it_alv2[].
LOOP AT it_alv1 INTO x_alv1 WHERE v_legf1 = x_alv-v_legf.
x_alv2 = x_alv1.
APPEND x_alv2 TO it_alv2 .
ENDLOOP.
DATA : it_fieldcat TYPE slis_t_fieldcat_alv.
DATA : x3_fieldcat LIKE LINE OF it_fieldcat.
CLEAR : x3_fieldcat,it_fieldcat[].
CLEAR x3_fieldcat.
x3_fieldcat-col_pos = '1'.
x3_fieldcat-fieldname = 'V_LEGF1'.
x3_fieldcat-reptext_ddic = text-111.
x3_fieldcat-ref_tabname = 'IT_ALV2'.
APPEND x3_fieldcat TO it_fieldcat.
CLEAR x3_fieldcat.
CLEAR x3_fieldcat.
x3_fieldcat-col_pos = '1'.
x3_fieldcat-fieldname = 'V_MSG'.
x3_fieldcat-reptext_ddic = text-112.
x3_fieldcat-ref_tabname = 'IT_ALV2'.
APPEND x3_fieldcat TO it_fieldcat.
CLEAR x3_fieldcat.
x_layout1-colwidth_optimize = 'X'.
x_layout1-zebra = 'X'.
IF it_alv2[] IS NOT INITIAL.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = x_repid2
is_layout = x_layout1
it_fieldcat = it_fieldcat
i_save = 'A'
i_callback_top_of_page = 'TOP'
is_variant = x_variant1
it_events = x_event
TABLES
t_outtab = it_alv2
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDIF.
ENDFORM.
FORM USER_COMMAND *
FORM top.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = 'Commentry'.
ENDFORM.
FORM BUILD_FIELDCAT *
FORM build_fieldcat CHANGING et_fieldcat TYPE slis_t_fieldcat_alv.
DATA: x1_fieldcat TYPE slis_fieldcat_alv.
CLEAR x1_fieldcat.
x1_fieldcat-col_pos = '1'.
x1_fieldcat-fieldname = 'V_LEGS'.
x1_fieldcat-reptext_ddic = text-108.
x1_fieldcat-ref_tabname = 'IT_ALV'.
APPEND x1_fieldcat TO et_fieldcat.
CLEAR x1_fieldcat.
x1_fieldcat-col_pos = '2'.
x1_fieldcat-fieldname = 'SUCCESS'.
x1_fieldcat-key = 'X'.
x1_fieldcat-reptext_ddic = text-109.
x1_fieldcat-ref_tabname = 'IT_ALV'.
APPEND x1_fieldcat TO et_fieldcat.
CLEAR x1_fieldcat.
x1_fieldcat-col_pos = '3'.
x1_fieldcat-fieldname = 'V_LEGF'.
x1_fieldcat-key = 'X'.
x1_fieldcat-reptext_ddic = text-110.
x1_fieldcat-ref_tabname = 'IT_ALV'.
APPEND x1_fieldcat TO et_fieldcat.
CLEAR x1_fieldcat.
ENDFORM. " build_fieldcat
FORM BUILD_LIST_HEADER *
FORM x_list_header.
DATA: x_list_header1 TYPE slis_listheader.
*-----List Header: type H
CLEAR x_list_header1 .
x_list_header1-typ = 'H'.
x_list_header1-info = text-105.
APPEND x_list_header1 TO x_list_header.
*-----List Key: type S
x_list_header1-typ = 'S'.
x_list_header1-key = text-106.
x_list_header1-info = v_total.
APPEND x_list_header1 TO x_list_header.
*-----List Key: Type S
CLEAR x_list_header1 .
x_list_header1-typ = 'S'.
x_list_header1-key = text-107.
x_list_header1-info = v_succsount.
APPEND x_list_header1 TO x_list_header.
ENDFORM. " build_list_header
FORM TOP_OF_PAGE *
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = x_list_header.
ENDFORM. " TOP_OF_PAGE
cheers,
Hema.

Similar Messages

  • Payment method not defaulting from Vendor master data

    Hi All
    I am running F110 payment run. In the Payment proposal SAP  is not pulling payment method from vendor master data for some invoice. we have like two payment methods , Sap is defaulting payment method for one type of payment method and not defaulting for the other...What could be the possible reasons?( for both the invoices We are not maintaining any payment method)

    Hi
    In F110 if payment methods are different from vendor master data and payment methods mentioned in parameters tab it will take payment methods from parameters tab, so that you have to give both payment methods in parameters tab so that it will consider both.

  • Profit Center not getting copied from WBS master data to settlement rule

    Hello,
    I am facing issues during settlement to G/L. From FI side we have set up some validations that the  FI postings shld always carry a Profit Ctr. Now when I am doing settlement to B/S account, the profit ctr from WBS master data gets copied to settlement details and hence on FI posting (Credit line).
    However when I am trying to settle to Expenxse/P&L account this is not happening. The profit Ctr is not getting copied from WBS master data to Settlement details and hence the settlement is not going thru. The profit derived is a dummy profit ctr and not the one on WBS master data.
    I have posted this query on FI forum too but no satisfactory answers.
    Pls let me know, what is the system behaviour....will the prof ctr on WBS master data gets copied on settlement rule details automatically ?
    Sarang

    Which exit do I use in OPSN? any thts or some exit in FI?
    I am on ECC-6.0...
    One thing to mention, the prof ctr is getting copied to settlement rules for Balance sheet account but not for P&L.This is more confusing...
    Sarang

  • Payment Terms should come from vendor master data

    When we create a new contract (ME31K) Z0NQ for the vendor  XYZ by default the payment terms that the contract retrieve is 1131, but in master data (XK03) for vendor XYZ I have payment terms 1011 defined.
    I already checked it in Purchase organization and CCode level.
    Please advise. Thanks!

    It should come from vendor master only butmake sure that you are creating cintract based onthe RFQ or some use exit is avtive for that.

  • Retrieving text from Vendor Master data

    Hi All,
    Please go through the navigation and query next to that...
    Vendor Master Change/ Display(XK02/XK03) --> Provide any Vendor number already created --->
    select the General Data ---> select Payment Transactions --> press enter to view the data -->
    Goto Menu Extras --> select texts  --> a window will pop up giving 2 rows for entering text as mentioned below.
    Accounting note
    Purchasing memo         
    We can enter the text beside the provision 1st line  else we can double click any one of them so that we will enter into a window to enter the long text or anything necessary.
    Now that in this concern my requirement is that i want to retrieve the text entered under the 1st line  or in the window which comes after double clicking Accounting note or Purchasing memo option basing on Vendor number or any other parameter or if any table where this data gets stored.
    Is there any program required to retrieve this text or any Function Module which retrieves this text or any coding avaliable please do send me as it is a very urgent requirement ....
    regards
    PSNG

    Could you please let me know, How to check through that FM as the parameters are confusing me when i went through them?
    regards
    PSNG

  • *Journal Entries while uploading the vendor master data from legacy system*

    hi SAP Folks,
    can any one of you tell me the journal entries while uploading the vendor master data from legacy system to SAP system.
    Eg: legacy system is having 10000 vendors list, 1 reconciliation account and $ 1000000. while uploading all these data from legacy system to SAP what are the journal entries we get.
    thanks in advance.
    Edited by: ravindranath manikonda on Nov 24, 2008 1:12 PM

    Hi
    you will be having  only one entry logically
    i.e. Opening Bal. clrng A/c Dr.
           To Vendor A/c Cr.
    regards

  • Error while replicating vendor master data from R3 to SRM

    Hi,
    I am trying to replicate Vendor master data from the R3 system to SRM system(7.0) for the first time and am facing the following error :
    Organizational unit 50000004  does not exist; check entries
    Message no. BBP_BUPA034
    I  have gone through the other posts with similar issues but haven't been able to find a solution.
    Any ideas?
    Thank you.

    hi sahlini
    did you create a vendor organisation structure via PPOCV_BBP ? SINCE YOU REFER THIS NUMBER 50000004 WHAT IS THIS?
    BR
    \MUTHU

  • How to create automatic creation of BP from customer and vendor master data

    Hi gurus,
    can any one tell how to create automatic creation of BP from customer and vendor master data.
    Please give me the steps.
    Thanks
    Sasikanth.

    HI,
    Goto SPRO\ Cross application components \ Master data synchronization \ Synchronization control.
    Assign account groups of customer and vendors to respective BP grouping. This setting is enough to create BP in background while creating customer / vendor. But the fields groups are very much important, ensure mandatory fields should be sync.
    rgds,
    Srini

  • Upload vendor master data from legacy system to internal table tcode xk01

    through batch input program how to upload vendor master data from legacy system to internal table and then to SAP R/3 database(transaction XK01) by using recording method.

    By learning the basics of BDC recording and the use of GUI_UPLOAD

  • Modify vendor number when replicating vendor master data from ECC to SRM

    Hi,
    Is there a way  to modify vendor number(manually input vendor number e.g. from a file) when replicating vendor master data from ECC to SRM using the vendor master data user exit (SAPMF02K)?
    Does anyone have documentation on the user exit, how do I use it??
    Thanks and Regards'
    David

    Hi David,
    Please go through the link below:
    [Enhancement SAPMF02K Vendor Master Data  - question about LIFNR;
    Regards
    Anirban

  • Function Module to send Vendor Master Data from SRM to ECC

    Hi Guys
    I heard there is a function module in SRM which can send Vendor Master Data from SRM to ECC please confirm for me if there is such a function Module and what is it called. Thanks

    Hi,
    Vendor Master data is replicated to SRM from ECC. Standard Transactions (BBPGETVD,..) will be used to replicate the data from ECC.
    Vendor Master will exists in ECC, so there is no point in sending the same back from SRM to ECC. If the requirement is the other way around, we can use the transaction BBPGETVD in SRM system.
    Hope this helps.
    Regards,
    Hemanth

  • Error importing vendor master data from ERP

    Hi experts,
    currently we are trying to import vendor master data from ERP to SAP Sourcing 9.
    We exported the data in an XML file by using the transaction BBP_ES_MAST_DOWNLOAD.
    We already imported all the dependencies like vendor account group, purchase org, regions etc. successfully.
    However, every time we are trying to import the vendor data we receive the same result:
    Data Import:
    Trace.txt:
    Do you have any hints why this happens?
    Thanks in advance and best regards,
    Johannes

    Hello Johannes,
    This looks to come from a custom script in your system.
    Go to Setup > Script Definition and check all scripts defined on class "Supplier" (starting with those on context: Import Lifecycle Event).
    Search for a script that starts with "throw doc.createApplicationException(test..."
    Regards,
    Bogdan

  • Header data not coming from vendor master when creating SA using BAPI

    Hello,
    I am creating SA using BAPI_SA_CREATE. I am passing the vendor code and other header related data in the header table of the BAPI.
    SA is created successfully with all the data that is passed to the BAPI. Now if the payment term and inco terms data is passed initial to BAPI then this data is not taken from vendor master. This data appears blank in SA.
    Shouldn't this data be picked up from vendor master as they are maintained properly in vendor master?
    I just need confirmation whether BAPI picks or not from vendor master if the data (payment term and inco terms) passed is initial.
    Thanks and Regards,
    Saba

    Hi,
    Are u passing X to corresponding fields of HEADER structure what ever you have populated in HEADER structure .

  • Bank account data is deleted from vendor master.

    Hello,
    My user wanted to change in the vendor master data Bank Account Number and VATnumber . So she deleted and entered new number for both . We we want to give confirmations we get confirmation only for VAT number . We saw in the field changes . There we can see New bank field new  as deleted  old empty space. More ever Bank accont and VAT account number have been deleted entered in the same manner.
    may i know the following things.
    1 What will the impact of when we delete and enter a new number and when we modify and enter new number.
    2.How do we do create again to confirm the changes (we have designed Bank account num as sensitive field)
    Thank you
    Chaithra

    Hi,
    Are u passing X to corresponding fields of HEADER structure what ever you have populated in HEADER structure .

  • Vendor Master Data Transfer Between the Clients

    Hello Everyone,
    I want to transfer Vendor master data between the clients, can any one help me in this Please?
    I don't want to use LSMW, Is there any other method by which i can copy the vendor between the clients or i have to do it manually?
    Please Help ASAP
    Thanks
    M

    Hi,
    You have to do necessary setting for ALE and IDOC will get generated and data will get transfer based on the Program Schedule in Bacground.
    You can schedule program in bacground as per your requirement of IDOC transfer and data generation from One Client to other. [i.e. end of the day, Hourly, monthly etc.]
    Regards,
    Manish

Maybe you are looking for