04-17-2010 9:53 PM
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
04-17-2010 11:00 PM
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]
04-17-2010 10:44 PM
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
04-18-2010 4:58 AM
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.
04-17-2010 11:00 PM
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]
04-18-2010 4:59 AM
Thanks Asik
I will try your response and will keep you posted.
Tks
Ram
04-18-2010 5:06 AM
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
04-18-2010 5:58 AM
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
04-18-2010 6:00 AM
04-18-2010 8:26 AM
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.
technical.com/Tutorials/BAPI/CustomBAPICreation/page1.htm
04-18-2010 2:04 PM
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
04-18-2010 6:48 PM
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
04-18-2010 9:07 PM
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
04-19-2010 4:34 AM
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
12-10-2013 10:57 AM
04-18-2010 6:29 AM
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