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 CALL TRANSCATION IN BAPI WITH INPUT

raj_sahay
Explorer
0 Likes
770

Hi Gurus ,

Plz help me , i want to create a BAPI , which call a transction

and pass input to the transcation , and return back with msg

thanks in advance

Raj sahay

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
731

Hi,

I'm not getting the point that you have to create a BAPI to call a transaction to pass the values to.

couldn't you just pass your values directly to the transaction then process the returned message?

If there is a reason that you have to use a BAPI please ad more details to your post.

6 REPLIES 6
Read only

Former Member
0 Likes
731

hi Raj,

this link can help you to create BAPI

http://www.erpgenie.com/abap/bapi/example.htm

Read only

Former Member
0 Likes
732

Hi,

I'm not getting the point that you have to create a BAPI to call a transaction to pass the values to.

couldn't you just pass your values directly to the transaction then process the returned message?

If there is a reason that you have to use a BAPI please ad more details to your post.

Read only

0 Likes
731

hi Guru

through vb application we want to call the transcation and get the msg from sap . for it i want to create BAPI which call the transcation as per vb appliction input and return to it with msg.

thanks in advance .

Read only

0 Likes
731

I would suggest for you not so consider creating BAPI of your own but first see of there is already a SAP standard BAPI that would suit your needs.

Then if you find it try looking into calling it through RFC.

Read only

0 Likes
731

Hi Raj,

You can create a RFC from T-code SE37.

In the import parameters, you can take the values from your VB/ Legacy application.

In the export parameters you can give out the values that you need to pass on to the VB/ Legacy application.

In the tables tab you can declare table which will be considered as internal table values. In the table parameters you can declare return structure BAPIRET2 and pass on the Call transaction return message using that.

Hope this helps you.

Thanks,

Arun

Read only

0 Likes
731

Hi Raj,

Record your transaction and build a bdc table <bdcdata>

Whatever data elements, structures and tables required for that bdc input - define them as IMPORT and TABLE parameters for the BAPI function module. Have one more TABLE parameter RETURN of type BAPIRET2.

Define a local table <messtab> of type BDCMSGCOLL.

After initial validation of input data, fill up <bdcdata> table and call your transaction:

CALL TRANSACTION tcode USING bdcdata

MODE 'N'

UPDATE 'S'

MESSAGES INTO messtab.

Loop through the <messtab> and construct RETURN table by calling function module 'BALW_BAPIRETURN_GET2'. This function module will construct the structure of type 'BAOURET2' from the message paramters. You can append these individual lines to the table RETURN. VB application can read the RETURN table and all the messages (readable text) will be available.

Psuedo Code:

==========

DATA: lv_type TYPE bapireturn-type,

lv_cl TYPE sy-msgid,

lv_num TYPE sy-msgno,

lv_par1 TYPE sy-msgv1,

lv_par2 TYPE sy-msgv2,

lv_par3 TYPE sy-msgv3,

lv_par4 TYPE sy-msgv4.

LOOP AT messtab.

MOVE: messtab-msgtyp TO lv_type,

messtab-msgid TO lv_cl,

messtab-msgnr TO lv_num,

messtab-msgv1 TO lv_par1,

messtab-msgv2 TO lv_par2,

messtab-msgv3 TO lv_par3,

messtab-msgv4 TO lv_par4.

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

type = lv_type

cl = lv_cl

number = lv_num

par1 = lv_par1

par2 = lv_par2

par3 = lv_par3

par4 = lv_par4

IMPORTING

return = wa_return.

APPEND wa_return to return.

ENDLOOP.

Regards

Suresh Radhakrishnan