Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

how to use BAPI "BAPI_PO_CHANGE" to change the extensions for items

Former Member
0 Kudos

hi,gurus,

i want to use the bapi "BAPI_PO_CHANGE" to change the extensions for po, both the extensions for header and items.

i can change the extensions for header successfully, but failed to change the extensions for items.

which puzzled me is that i can use "BAPI_PO_CREATE1" create the po including the extensions for both the header and items.

2 REPLIES 2

Former Member
0 Kudos

Hi,

Just see this sample code.

&----


*& Report YDM_PO_CREATE *

*& *

&----


*& *

*& *

&----


REPORT ydm_po_create.

Input File Declaration

TYPES: BEGIN OF ty_input_file,

column1 TYPE char50,

column2 TYPE char50,

column3 TYPE char50,

column4 TYPE char50,

column5 TYPE char50,

column6 TYPE char50,

column7 TYPE char50,

column8 TYPE char50,

column9 TYPE char50,

column10 TYPE char50,

column11 TYPE char50,

column12 TYPE char50,

column13 TYPE char50,

column14 TYPE char50,

column15 TYPE char50,

column16 TYPE char50,

column17 TYPE char50,

column18 TYPE char50,

END OF ty_input_file.

DATA: i_input_file TYPE STANDARD TABLE OF ty_input_file,

wa_input_file TYPE ty_input_file.

CONSTANTS: c_path TYPE char20 VALUE 'C:\',

c_mask TYPE char9 VALUE ',.,..',

c_mode TYPE char1 VALUE 'O',

c_filetype TYPE char10 VALUE 'ASC',

c_x TYPE char01 VALUE 'X'.

PARAMETERS : p_fname LIKE rlgrap-filename.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.

Browse Presentation Server

PERFORM f4_presentation_file.

START-OF-SELECTION..

Read presentation server file

PERFORM f1003_upload_file.

IF NOT i_input_file[] IS INITIAL.

PERFORM split_data.

ENDIF.

*&----


*& Form f4_presentation_file

*&----


*& F4 Help for presentation server

*&----


FORM f4_presentation_file .

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

def_path = c_path

mask = c_mask

mode = c_mode

title = text-001

IMPORTING

filename = p_fname

EXCEPTIONS

inv_winsys = 1

no_batch = 2

selection_cancel = 3

selection_error = 4

OTHERS = 5.

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. " f4_presentation_file

*&----


*& Form f1003_upload_file

*&----


*& Upload File

*&----


FORM f1003_upload_file .

DATA: lcl_filename TYPE string.

lcl_filename = p_fname.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = lcl_filename

filetype = c_filetype

has_field_separator = c_x

TABLES

data_tab = i_input_file

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.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

EXIT.

ENDIF.

ENDFORM. " f1003_upload_file

&----


*& Form split_data

&----


Collect data for creating Purchase Order

-


FORM split_data .

DATA: i_poitem TYPE STANDARD TABLE OF bapimepoitem,

i_poitemx TYPE STANDARD TABLE OF bapimepoitemx,

i_poitem_sch TYPE STANDARD TABLE OF bapimeposchedule,

i_poitem_schx TYPE STANDARD TABLE OF bapimeposchedulx,

i_acct_ass TYPE STANDARD TABLE OF bapimepoaccount,

i_acct_assx TYPE STANDARD TABLE OF bapimepoaccountx,

i_services TYPE STANDARD TABLE OF bapiesllc ,

i_srvacc TYPE STANDARD TABLE OF bapiesklc,

i_return TYPE STANDARD TABLE OF bapiret2,

wa_header TYPE bapimepoheader,

wa_headerx TYPE bapimepoheaderx,

wa_poitem TYPE bapimepoitem,

wa_poitemx TYPE bapimepoitemx,

wa_poitem_sch TYPE bapimeposchedule,

wa_poitem_schx TYPE bapimeposchedulx,

wa_acct_ass TYPE bapimepoaccount,

wa_acct_assx TYPE bapimepoaccountx,

wa_services TYPE bapiesllc,

wa_srvacc TYPE bapiesklc,

wa_return TYPE bapiret2,

ws_po TYPE bapimepoheader-po_number.

break gbpra8.

wa_services-pckg_no = 10.

wa_services-line_no = 1.

wa_services-outl_no = '0'.

wa_services-outl_ind = c_x.

wa_services-subpckg_no = 20.

APPEND wa_services TO i_services.

wa_srvacc-pckg_no = 10.

wa_srvacc-line_no = 1.

wa_srvacc-serno_line = 01.

wa_srvacc-serial_no = 01.

wa_srvacc-percentage = 100.

APPEND wa_srvacc TO i_srvacc.

LOOP AT i_input_file INTO wa_input_file.

IF wa_input_file-column2 EQ 'HD'.

wa_header-doc_type = wa_input_file-column3.

wa_header-creat_date = sy-datum.

wa_header-created_by = sy-uname.

wa_header-vendor = wa_input_file-column4.

PERFORM conversion_output USING wa_header-vendor

CHANGING wa_header-vendor.

wa_header-comp_code = 'DE03'.

wa_header-purch_org = 'DE03'.

wa_header-pur_group = 'DE1'.

wa_header-vper_start = wa_input_file-column9.

wa_header-vper_end = wa_input_file-column10.

wa_headerx-comp_code = c_x.

wa_headerx-doc_type = c_x.

wa_headerx-creat_date = c_x.

wa_headerx-created_by = c_x.

wa_headerx-vendor = c_x.

wa_headerx-purch_org = c_x.

wa_headerx-pur_group = c_x.

wa_headerx-vper_start = c_x.

wa_headerx-vper_end = c_x.

ENDIF.

IF wa_input_file-column2 EQ 'IT'.

wa_poitem-po_item = wa_input_file-column3.

wa_poitem-short_text = wa_input_file-column6.

wa_poitem-plant = wa_input_file-column8.

wa_poitem-quantity = '1'.

wa_poitem-tax_code = 'V0'.

wa_poitem-item_cat = 'D'.

wa_poitem-acctasscat = 'K'.

wa_poitem-matl_group = wa_input_file-column7.

wa_poitem-pckg_no = '10'.

APPEND wa_poitem TO i_poitem .

wa_poitemx-po_item = wa_input_file-column3.

wa_poitemx-po_itemx = c_x.

wa_poitemx-short_text = c_x.

wa_poitemx-plant = c_x.

wa_poitemx-quantity = c_x.

wa_poitemx-tax_code = c_x.

wa_poitemx-item_cat = c_x.

wa_poitemx-acctasscat = c_x.

wa_poitemx-matl_group = c_x.

wa_poitemx-pckg_no = c_x.

APPEND wa_poitemx TO i_poitemx.

wa_poitem_sch-po_item = wa_input_file-column3.

wa_poitem_sch-delivery_date = sy-datum.

APPEND wa_poitem_sch TO i_poitem_sch.

wa_poitem_schx-po_item = wa_input_file-column3.

wa_poitem_schx-po_itemx = c_x.

wa_poitem_schx-delivery_date = c_x.

APPEND wa_poitem_schx TO i_poitem_schx.

wa_acct_ass-po_item = 10.

wa_acct_ass-serial_no = 01.

wa_acct_ass-gl_account = '0006360100'.

wa_acct_ass-co_area = '1000'.

wa_acct_ass-costcenter = 'KC010000'.

APPEND wa_acct_ass TO i_acct_ass.

wa_acct_ass-po_item = 10.

wa_acct_ass-serial_no = 02.

wa_acct_ass-gl_account = '0006360100'.

wa_acct_ass-co_area = '1000'.

wa_acct_ass-costcenter = 'KC010000'.

APPEND wa_acct_ass TO i_acct_ass.

wa_acct_assx-po_item = 10.

wa_acct_assx-serial_no = 01.

wa_acct_assx-po_itemx = c_x.

wa_acct_assx-serial_nox = c_x.

wa_acct_assx-gl_account = c_x.

wa_acct_assx-co_area = c_x.

wa_acct_assx-costcenter = c_x.

APPEND wa_acct_assx TO i_acct_assx.

wa_acct_assx-po_item = 10.

wa_acct_assx-serial_no = 02.

wa_acct_assx-po_itemx = c_x.

wa_acct_assx-serial_nox = c_x.

wa_acct_assx-gl_account = c_x.

wa_acct_assx-co_area = c_x.

wa_acct_assx-costcenter = c_x.

APPEND wa_acct_assx TO i_acct_assx.

wa_services-pckg_no = 20.

wa_services-line_no = 2.

wa_services-service = wa_input_file-column9.

wa_services-quantity = '100'.

wa_services-gr_price = '100'.

wa_services-userf1_txt = wa_input_file-column13.

APPEND wa_services TO i_services.

wa_srvacc-pckg_no = 20.

wa_srvacc-line_no = 1.

wa_srvacc-serno_line = 02.

wa_srvacc-serial_no = 02.

wa_srvacc-percentage = 100.

APPEND wa_srvacc TO i_srvacc.

ENDIF.

ENDLOOP.

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

poheader = wa_header

poheaderx = wa_headerx

POADDRVENDOR =

TESTRUN =

MEMORY_UNCOMPLETE =

MEMORY_COMPLETE =

POEXPIMPHEADER =

POEXPIMPHEADERX =

VERSIONS =

NO_MESSAGING =

NO_MESSAGE_REQ =

NO_AUTHORITY =

NO_PRICE_FROM_PO =

IMPORTING

exppurchaseorder = ws_po

EXPHEADER =

EXPPOEXPIMPHEADER =

TABLES

return = i_return

poitem = i_poitem

poitemx = i_poitemx

POADDRDELIVERY =

poschedule = i_poitem_sch

poschedulex = i_poitem_schx

poaccount = i_acct_ass

POACCOUNTPROFITSEGMENT =

poaccountx = i_acct_assx

POCONDHEADER =

POCONDHEADERX =

POCOND =

POCONDX =

POLIMITS =

POCONTRACTLIMITS =

poservices = i_services

posrvaccessvalues = i_srvacc

POSERVICESTEXT =

EXTENSIONIN =

EXTENSIONOUT =

POEXPIMPITEM =

POEXPIMPITEMX =

POTEXTHEADER =

POTEXTITEM =

ALLVERSIONS =

POPARTNER =

.

break gbpra8.

LOOP AT i_return INTO wa_return.

ENDLOOP.

ENDFORM. " split_data

&----


*& Form conversion_output

&----


Conversion exit input

-


FORM conversion_output USING p_ip

CHANGING p_op.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = p_ip

IMPORTING

output = p_op.

ENDFORM. " conversion_output

Regards,

If helpful reward with points(Don't forget).

0 Kudos

hi, shiva kumar ,

i can use the bapi "bapi_po_create1", the code isn't i needed, my question is how to use another bapi "bapi_po_change" change the extensions for line items. the code doesn't mention the extensions.

regards,

kai lee

2008-04-09