Application Development and Automation 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: 
Read only

How to pass custom Fields to BAPI?

Former Member
0 Likes
2,645

Hi,

How to pass Custom Fields to BAPi?

I have to pass custom fields(Cretaed New structure) to Zversion of exiating BAPI.Where can i Pass in IMPORT or EXPORT.

Regards,

Chow.

Hi,

How to pass Custom Fields to BAPi?

I have to pass custom fields(Cretaed New structure) to Zversion of exiating BAPI.Where can i Pass in IMPORT or EXPORT.

Regards,

Chow.

2 REPLIES 2
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,309

It depends on the BAPI. Which BAPI are you using?

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,309

Create New Function module and maintain attributes like Remote enabled.

Let us say Example for Sales order,you have some custom fields.

Your ZFM Name like ZBAPI_SALESORDER_CREATEFROMDAT

call sap Standard Function module within your Zfunction module.

Pass the all parameter to SAP Function module and Extension structure ,here we can send the data to Custom Fields.

See the example code below...

FUNCTION zbapi_salesorder_createfromdat.

*"----


""Local interface:

*" IMPORTING

*" VALUE(SALESDOCUMENTIN) LIKE BAPIVBELN-VBELN OPTIONAL

*" VALUE(ORDER_HEADER_IN) LIKE BAPISDHD1 STRUCTURE BAPISDHD1

*" VALUE(ORDER_HEADER_INX) LIKE BAPISDHD1X STRUCTURE BAPISDHD1X

*" OPTIONAL

*" VALUE(SENDER) LIKE BAPI_SENDER STRUCTURE BAPI_SENDER OPTIONAL

*" VALUE(BINARY_RELATIONSHIPTYPE) LIKE BAPIRELTYPE-RELTYPE

*" OPTIONAL

*" VALUE(INT_NUMBER_ASSIGNMENT) LIKE BAPIFLAG-BAPIFLAG OPTIONAL

*" VALUE(BEHAVE_WHEN_ERROR) LIKE BAPIFLAG-BAPIFLAG OPTIONAL

*" VALUE(LOGIC_SWITCH) LIKE BAPISDLS STRUCTURE BAPISDLS OPTIONAL

*" VALUE(TESTRUN) LIKE BAPIFLAG-BAPIFLAG OPTIONAL

*" VALUE(CONVERT) LIKE BAPIFLAG-BAPIFLAG DEFAULT SPACE

*" EXPORTING

*" VALUE(SALESDOCUMENT) LIKE BAPIVBELN-VBELN

*" TABLES

*" RETURN STRUCTURE BAPIRET2 OPTIONAL

*" ORDER_ITEMS_IN STRUCTURE BAPISDITM OPTIONAL

*" ORDER_ITEMS_INX STRUCTURE BAPISDITMX OPTIONAL

*" ORDER_PARTNERS STRUCTURE BAPIPARNR

*" ORDER_SCHEDULES_IN STRUCTURE BAPISCHDL OPTIONAL

*" ORDER_SCHEDULES_INX STRUCTURE BAPISCHDLX OPTIONAL

*" ORDER_CONDITIONS_IN STRUCTURE BAPICOND OPTIONAL

*" ORDER_CFGS_REF STRUCTURE BAPICUCFG OPTIONAL

*" ORDER_CFGS_INST STRUCTURE BAPICUINS OPTIONAL

*" ORDER_CFGS_PART_OF STRUCTURE BAPICUPRT OPTIONAL

*" ORDER_CFGS_VALUE STRUCTURE BAPICUVAL OPTIONAL

*" ORDER_CFGS_BLOB STRUCTURE BAPICUBLB OPTIONAL

*" ORDER_CFGS_VK STRUCTURE BAPICUVK OPTIONAL

*" ORDER_CFGS_REFINST STRUCTURE BAPICUREF OPTIONAL

*" ORDER_CCARD STRUCTURE BAPICCARD OPTIONAL

*" ORDER_TEXT STRUCTURE BAPISDTEXT OPTIONAL

*" ORDER_KEYS STRUCTURE BAPISDKEY OPTIONAL

*" EXTENSIONIN STRUCTURE BAPIPAREX OPTIONAL

*" PARTNERADDRESSES STRUCTURE BAPIADDR1 OPTIONAL

*"----


READ TABLE extensionin WITH KEY structure = 'BAPE_VBAK'.

IF sy-subrc = 0.

MOVE order_header_in-ref_1_s TO extensionin-valuepart1+105(12).

MODIFY extensionin INDEX sy-tabix.

CLEAR extensionin.

ELSE.

extensionin-structure = 'BAPE_VBAK'.

MOVE order_header_in-ref_1_s TO extensionin-valuepart1+105(12).

APPEND extensionin.

CLEAR extensionin.

ENDIF.

  • << End insert >>

*-- Validate Credits for any number misrepresentation.

APPEND LINES OF extensionin TO int_extensionin.

  • Call SAP standard BAPI to create order

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

EXPORTING

salesdocumentin = salesdocumentin

order_header_in = order_header_in

order_header_inx = order_header_inx

sender = sender

binary_relationshiptype = binary_relationshiptype

int_number_assignment = int_number_assignment

behave_when_error = behave_when_error

logic_switch = logic_switch

testrun = testrun

convert = convert

IMPORTING

salesdocument = salesdocument

TABLES

return = return

order_items_in = order_items_in

order_items_inx = order_items_inx

order_partners = order_partners

order_schedules_in = order_schedules_in

order_schedules_inx = order_schedules_inx

order_conditions_in = order_conditions_in

order_cfgs_ref = order_cfgs_ref

order_cfgs_inst = order_cfgs_inst

order_cfgs_part_of = order_cfgs_part_of

order_cfgs_value = order_cfgs_value

order_cfgs_blob = order_cfgs_blob

order_cfgs_vk = order_cfgs_vk

order_cfgs_refinst = order_cfgs_refinst

order_ccard = order_ccard

order_text = order_text

order_keys = order_keys

extensionin = extensionin

partneraddresses = partneraddresses.

Reward Points if it is helpful

Thanks

Seshu