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

BAPI: Data type string in FM's structure

Former Member
0 Likes
1,879

Hello experts,

I have created a BAPI and use FM as a part of it. However, when I use the structure for the export parameter as a string field and get error message "String not allowed in structure".

Then I tried to use data type BAPITLINE and it's work fine, but it can only use for CHAR132 (my data is about 270 - 300 characters long)

Any solution for creating BAPI and use string as an import parameter ???

6 REPLIES 6
Read only

Former Member
0 Likes
1,198

Hi,

use SRMHLSTRNG type, it is string type and your function will be ok.

FUNCTION ZHHTEST01.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(ILINE) TYPE  SRMHLSTRNG
*"  EXPORTING
*"     REFERENCE(ELINE) TYPE  SRMHLSTRNG
*"----------------------------------------------------------------------

ENDFUNCTION.

thank you

Jan

Read only

Former Member
0 Likes
1,198

Hi,

Try type CHAR339.

ParameterName      Type      Associated Type            Short Text
MY_String          TYPE	     CHAR339	                Character 339

Regards,

Jovito.

Read only

Former Member
0 Likes
1,198

Thank you for your reply,

I have tried to use data type SRMHLSTRNG but it's having an error "Data type SRMHLSTRNG cannot be used for methods" in SWO1

and then I tried to change data type to char339 but it's having an error "Data type CHAR339 cannot be used for methods".

Any solution for this, please help !!

Read only

0 Likes
1,198

Hi Verdam,

Try creating your own data element in SE11 and using it.

I was able to use CHAR339 as both input and output parameters of an RFC enabled FM. So not sure why you are receiving that error.

Regards,

Jovito

Read only

0 Likes
1,198

There are less restrictions on RFC enabled FM than on BAPI.

Check [Actions in the ABAP Dictionary |http://help.sap.com/saphelp_NW70EHP1core/helpdata/en/43/b46c3953c111d395fa00a0c94260a5/frameset.htm] in [BAPI Programming Guide (CA-BFA)|http://help.sap.com/saphelp_NW70EHP1core/helpdata/en/e0/9eb2370f9cbe68e10000009b38f8cf/frameset.htm]

Conventions for BAPI Data Structures

Each parameter must refer to a data structure in the ABAP Dictionary. In the case of structured parameters this is always to the whole BAPI data structure. But if the parameter consists of only one field, it must refer to a field in a BAPI structure.

Conventions for BAPI/ALE Integration

So that an IDoc for asynchronous communication can be generated from a BAPI, the following conditions must be satisfied:

BAPI structure names must not be longer than 27 characters, otherwise the automatically generated name for the associated segment will be too long and will have to be changed manually later.

Reason : The segment is generated following the convention <BAPI structure name> + <three digit number>.

This graphic is explained in the accompanying text

Single fields in a data structure can only be a maximum of 250 bytes.

So the length of any single parameter (not structure) of the BAPI can not exceed 250.

Regards,

Raymond

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,198

I don't think it is possible to use a STRING type parameter in a BAPI, convert the string to an internal table of text of structure BAPITGB.

Regards,

Raymond