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: 

Passing internal table with a field of type string to & from BAPI

Former Member
0 Kudos

Hello ABAP gurus,

I have a simple BAPI which has to send back an internal table.

Internal table structure is as follows

DATA: BEGIN OF itab OCCURS 0,

config_id(8),

blobdata like zstring,

END OF itab.

where zstring is a string of variable length.

When I try to activate the BAPI I get a message

"itab" must be a flat structure. You cannot use internal tables, strings, references or structures as components.

However, just for testing, I changed blobdata to type of char and I can successfully activate and use the BAPI.

But, our requirement is to pass a string of variable length.

How can I resolve this issue? I have searched sdn and other blogs but didn't help so far.

Any feedback on this will be highly appreciated.

Thanks

Ram

1 ACCEPTED SOLUTION

asik_shameem
Active Contributor
0 Kudos

Hi,

I don't think BAPI allows STRING type or CHAR type of having more than 255 characters. Try to use structure like BAPITGB.

[http://help.sap.com/saphelp_46c/helpdata/EN/c8/164d84b11711d2ad51080009b0fb56/frameset.htm]

14 REPLIES 14

Former Member
0 Kudos

Hi

1) Create in se11 the structure of your internal table

2) Create a table type in se11 based on your structure from 1)

use the table type in your import, expart or changing parameter of the bapi function.

Rene

0 Kudos

Thanks Rene for the response. However, I have already done it. In the structure, one of the field is STRINGS and that is causing the problem.

asik_shameem
Active Contributor
0 Kudos

Hi,

I don't think BAPI allows STRING type or CHAR type of having more than 255 characters. Try to use structure like BAPITGB.

[http://help.sap.com/saphelp_46c/helpdata/EN/c8/164d84b11711d2ad51080009b0fb56/frameset.htm]

0 Kudos

Thanks Asik

I will try your response and will keep you posted.

Tks

Ram

0 Kudos

Hi Asik

Tried your suggestion and used TYPE BAPITGB. When I tried activating the BAPI, I get the following error

"Only tables with flat line structure are allowed in RFC"

Any other suggestions or comments will be highly appreciated.

Tks

Ram

0 Kudos

Hi

You are using the TABLES tab of the function. This clearly can not work.

You need to use a tabletype and use the import, export or changing tab of the Function. Then clearly it works.

(code)

FUNCTION ZSY_TEST.

*"----


""Update Function Module:

*"

""Local Interface:

*" IMPORTING

*" VALUE(IT_TABLE) TYPE ZSY_T_TEST

*"----


ZSY_T_TEST is atbale and has two fields .

Rene

0 Kudos

BAPITGB is a structure and not a Tabletype

Rene

0 Kudos

Hi,

As Rene told, create a table type like ZBAPI_TT_TEST with BAPITGB in SE11->Data Type->Table type and use that as CHANGING parameter. Make sure you are following the BAPI guidelines and naming conventions.

FUNCTION ZBAPI_TEST.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  CHANGING
*"     REFERENCE(IT_TEXT) TYPE  ZBAPI_TT_TEST
*"----------------------------------------------------------------------

....

ENDFUNCTION.

Check the following link. I don't know, why am not able to post the link here. I just broke into two.

http://www.sap

technical.com/Tutorials/BAPI/CustomBAPICreation/page1.htm

0 Kudos

Thanks a lot for all the responses. I am trying all the suggestions one by one

To start with I tried Rene and Ranjit's suggesion as follows, where I can define the internal table in importing tab successfully.

FUNCTION ZBAPI_BLOBDATA_SEARCH.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(VBELN) TYPE VBELN_VA

*" EXPORTING

*" VALUE(MESSAGE) TYPE ZRETURN_MESSAGE

*" CHANGING

*" VALUE(ITAB) TYPE ZBLOBDATA

*"----


select blobdata from ZBLOBDATA into itab.

append itab.

endselect.

-


But when i try to activate the bapi, i get the message " itab is not an internal table - the "OCCURS n" specification is missing.

I do

0 Kudos

Please you have to read what we tell you:

TRANSACTION SE11:

You have to create yourself a table type first. Before you have not defned your table type correctly in SE11, you can not create your function correctly.

Regards

Rene

0 Kudos

Hello friends,

Thanks a lot to all those who responded. I appreciate it a lot.

Rene, as you had suggested I used table type in the tab 'changing' and it did the trick. Thanks a lot for responding multiple times pointing out my mistake. I was using 'structure' instead of 'table type'.

Thanks for helping me to resolve this issue.

Ram

0 Kudos

Hi Prasad ,

From next time when you seek help ,kindly read before you develop your code .

As because you might make mistake I had already mentioned that you have to create a table type .

Anyways be careful when your read to avoid mistakes and time delays in developments .

Kind regards,

Ranjita

0 Kudos

This made me giggle

Thanks Rene.

Regards,

Bruno

former_member196299
Active Contributor
0 Kudos

Hi Prasad ,

Try this way :

Acc to your requirement ,create a structure with a parameter and a string , create a table type for that structure .

use that table type in the changing parameter as you need that bapi to accept and return a table .

for the below example , ZTEST_05 is a structure , ZTT_TEST_05 is a table type of ZTEST_05 .

ZTEST_05 has got 2 fields , one is a param of type char(8) and another is a string of type STRING .

I created the below mentioned BAPI and I was able to activate it without any errors .

FUNCTION ZTEST_BAPI_ITAB_01.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(BAPI_P1) TYPE ZTEST_05

*" CHANGING

*" VALUE(BAPI_CP1) TYPE ZTT_TEST_05

*"----


ENDFUNCTION.

Revert if any issues .

Regards,

Ranjita