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

Regarding ZBAPI

Former Member
0 Likes
815

Hello Sir,

I have created a ZBAPI for insert data into SAP ZTable from VB.  I have define Export Paramter as Return and Table Parameter as IMport/Export.

Finaly I have written following Code.

*"*"Local Interface:

*"  EXPORTING

*"     VALUE(RETURN) TYPE  BAPIRET2

*"  TABLES

*"      ZBAPIXXXX STRUCTURE  ZBAPIXXXX

*"----------------------------------------------------------------------

MODIFY zpmxxxx FROM  zbapixxxx.       "  INSERT zpmxxxx FROM  zbapixxxx

I have used this data insertion from se37. It is insert data into ZTable but when insert data using SWO1 , it does not insert.

I have registered in SWO1 also. It shows in BAPI t-code.

Please guide me how to this.

Thanks!

Ram Shanker


.

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
777

Replace

MODIFY zpmxxxx FROM  zbapixxxx.

with

MODIFY zpmxxxx FROM  TABLE zbapixxxx.

Of course a better code would look like

LOOP AT zbapixxxx ASSIGNING <fs>.

" Perform check, check table and the like and fill RETURN if error

ENDLOOP.

IF RETURN-TYPE NE 'E'.

CALL FUNCTION 'ZBAPIXXX_UPDATE' IN UPDATE TASK " In his update FM, exectute MODIFY/INSERT

  TABLES

     zbapixxxx = zbapixxx.

ENDIF.

Regards,

Raymond

7 REPLIES 7
Read only

Phillip_Morgan
Contributor
0 Likes
777

Don't forget that you need a commit.

If this Bapi is to be called from the outside (RFC) then you will need to use BAPI_TRANSACTION_COMMIT. (or put a commit into your function)

Read only

0 Likes
777

Hi,

I have already put this command.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

But but it does not work means not insert data into ztable.

Ram

Read only

RaymondGiuseppi
Active Contributor
0 Likes
778

Replace

MODIFY zpmxxxx FROM  zbapixxxx.

with

MODIFY zpmxxxx FROM  TABLE zbapixxxx.

Of course a better code would look like

LOOP AT zbapixxxx ASSIGNING <fs>.

" Perform check, check table and the like and fill RETURN if error

ENDLOOP.

IF RETURN-TYPE NE 'E'.

CALL FUNCTION 'ZBAPIXXX_UPDATE' IN UPDATE TASK " In his update FM, exectute MODIFY/INSERT

  TABLES

     zbapixxxx = zbapixxx.

ENDIF.

Regards,

Raymond

Read only

0 Likes
777

Thanks Raymonds !

Now It is working.

Ram

Read only

0 Likes
777

No problem, your FM was trying to insert/update from the header line of the TABLE parameter.

Regards,

Raymond

Read only

Former Member
0 Likes
777

Try with below way for more information please read the modify keyword documentation

"MODIFY TABLE itab FROM line."

Regards

Mahesh

Read only

Former Member
0 Likes
777

Hi,

MODIFY zpmxxxx FROM table zbapixxxx.  

if sy-subrc eq 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

endif.

thanks

Mani