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

Error in BDC program

manish_malakar0316
Active Participant
0 Likes
4,317

Hi all,

I have created a BDC call transaction program manually. In my program , I am using the ABAP Test Cockpit to check if my program is devoid of any errors. However, when I am passing all the values in the formal parameter FILL_DATA , there is an error showing that The literal "' '" is not type-compatible with the formal parameter "P_DYNPRO".  I have attached the screenshot below for your reference.  Initially I had not declared the types of the formal parameters and the syntax check was fine. But on running the ABAP Test Cockpit, there was an error showing Missing type declaration of "Formal" parameter.  Hence I had to declare the data types. Please help me to eradicate this error so that the Abap Test Cockpit is successfull as it is mandatory for me to make sure that there are no errors displaying in the ATC. I have also attached my program with this issue, so plz refer to it.

Below are the screens of my program:

In the above screen, the formal parameters are declared as per the data types from the structure bdcdata. Now on checking the program, I am getting the following error:

Kindly help me resolve this issue.

Regards.

Manish Malakar.

22 REPLIES 22
Read only

Former Member
0 Likes
3,984

Hi,

Instead of '   ' in the 2nd parameter(DYNPRO) of FILL_DATA pass '0000'.

Regards,

DPM

Read only

0 Likes
3,981

Hi, I used your approach but I am gettin the below shown error:

Read only

0 Likes
3,981

Manish

Declare 5 variables of same type as suboutine type. Then before calling each perform assign values whatever program name etc and pass them it will not show any error.

Nabheet

Read only

0 Likes
3,981

Hi,

While passing value, convert everything to character type and then call the subroutine 'FILL_DATA'.

Regards,

DPM

Read only

0 Likes
3,981

But one of the fields is of NUMC type, how can I convert it to CHAR data type?

Read only

0 Likes
3,981

Suppose,

Reason code is Numc 2.

Declare a variable lv_reasoncode of type C having the same length.

* Numc to character conversion

Clear lv_reason_code.

lv_reason_code = Reason code.

Now in PERFORM FILL_DATA pass lv_reason_code instead of reason code.

Regards,

DPM

Read only

0 Likes
3,981

The error still persists

Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
3,981

Hi Manish

Create local variable of same type as subroutine and then pass them in Perform call

Nabheet

Read only

0 Likes
3,981

I did try that, but the error persists  😞  However I did use "type any" for all the 5 formal  parameters, and the errors were gone. So do I use that approach?

Read only

matt
Active Contributor
0 Likes
3,981

No. Strongly type as much as possible. Read my blog here for why:

The correct solution is to create a local variable of the right type and put the value into that.

Read only

Former Member
0 Likes
3,981

Hi,

It is due to mismatch in data type - formal parameter data type not matching with actual parameter.

Regards,

Read only

0 Likes
3,981

Hi, u r correct. So how can I rectify this? 

Read only

Former Member
0 Likes
3,981

Hi,

where ever you are passing nothing just try to pass space as below.

perform fill_data using '8945' tp_val space space '58i'.

regards,

Aswath

Read only

0 Likes
3,981

Sorry, but this approach doesnt remove the error.

Read only

0 Likes
3,981

That's not the correct approach but remove the types in the FORM routine declaration, just:

FORM fill_data USING p_program
                     p_dynpro

                     p_dynbegin

                     p_fnam

                     p_fval.


...


ENDFORM.           

Read only

0 Likes
3,981

Hi,

Do what Matthew suggested.

In FORM POPU_BDCDATA

1) Declare five local variables :

    DATA : lv_prog        TYPE bdc_prog,

               lv_dynnr       TYPE bdc_dynr,

               lv_dynbegin  TYPE bdc_start,

               lv_fld            TYPE fnam_____4,

               lv_val           TYPE bdc_val.

2) Assign the actual parameters to the local variable.

       lv_prog = 'LGC\   '.

3) perform fill_data using lv_prog lv_dynnr lv_dynbegin lv_fld lv_val.

4)   After each perform call, initialize the local variables.

     clear lv_prog.

Regards,

DPM

Read only

0 Likes
3,981

Hi Renan,.

The thing is initially I didnt mention the data types at all for the formal parameters. But the ABAP Test Cockpit check was highlighting the error . Then I realised that the data types had to be declared for the ATC to be successfull. Thats why I cannot remove the types in the FORM routine as you mentioned.

Read only

0 Likes
3,981

Hi Debopriyo,

I have a query regarding this approach. I am dealing with 2 screens in my BDC, 9201 and 9999. So how do I assign 2 screens under the lv_dynnr variable as we are basically declaring them as constants as per your approach. lv_dynnr has to be dynamic since 2 screens are in consideration.

Regards.

Manish.

Read only

0 Likes
3,981

So in this case you will need to follow the other advices from our friends: you will need to create constants/variables with same type insted use fixed strings.

Example:

FORM POPU_BDCDATA .

  CONSTANTS: lc_space   TYPE sy-dinnr  VALUE space,

  lc_initial_screen TYPE bdc_start VALUE 'X'.

 

  PERFORM:

   FILL_DATA  USING   

       LGC/SAPLMMFGWW_SL_TRANSFER '9201' lc_initial_screen

       lc_space lc_space,

   FILL_DATA  USING    

       lc_space lc_space lc_space

       'BDC_CURSOR' 'GS_CYL_REASON_IP-CYL_BARCODE',

   FILL_DATA  USING    

       lc_space lc_space lc_space

       'BDC_OKCODE' '=ENTR',

   FILL_DATA  USING    

       lc_space  lc_space  lc_space        

       'GS_CYL_REASON_HD-REASON_CODE' <G_FIELD>-HD_REASON_CODE,

   FILL_DATA  USING    

       lc_space lc_space lc_space

       'GS_CYL_REASON_IP-CYL_BARCODE' <G_FIELD>-CYL_BARCODE,

  FILL_DATA  USING     

       lc_space lc_space lc_space

       'GS_CYL_REASON_IP-REASON_CODE' <G_FIELD>-IP_REASON_CODE,

  FILL_DATA  USING     

       '/LGC/SAPLMMFGWW_SL_TRANSFER' '9201' 'lc_initial_screen

       lc_space lc_space,

  FILL_DATA  USING     

       lc_space lc_space lc_space

       'BDC_CURSOR' 'GS_CYL_REASON_IP-CYL_BARCODE',

  FILL_DATA  USING     

       lc_space lc_space lc_space

       'BDC_OKCODE' '=SAVE',

  FILL_DATA  USING     

       lc_space lc_space lc_space

       'GS_CYL_REASON_HD-REASON_CODE' <G_FIELD>-HD_REASON_CODE,

FILL_DATA  USING      

       lc_space lc_space lc_space

       'GS_CYL_REASON_IP-REASON_CODE' <G_FIELD>-IP_REASON_CODE,

FILL_DATA  USING      

       '/LGC/SAPLMMFGWW_SG_FILLING' '9999' lc_initial_screen

       lc_space lc_space,

FILL_DATA  USING      

       lc_space lc_space lc_space

       'BDC_CURSOR' 'G_MESSAGE1',

FILL_DATA  USING      

       lc_space lc_space lc_space

       'BDC_OKCODE' '=ENTR '.

ENDFORM.                    " POPU_BDCDATA

Read only

0 Likes
3,981

You mentioned :

CONSTANTS: lc_space   TYPE sy-dynnr VALUE space,

  lc_initial_screen TYPE bdc_start VALUE 'X'.

If this is the case, then how is this possible:

PERFORM:

   FILL_DATA  USING   

       LGC/SAPLMMFGWW_SL_TRANSFER '9201' lc_initial_screen

       lc_space lc_space,

you have used lc_space for Fnam and Fval whereas lc_space is declared as a type of sy-dynnr. Moreover I think lc_space should be of type BDC_DYNR (as per BDCDATA structure) which is of NUMC4 data type. So wont there be a type mismatch in this case?

Read only

0 Likes
3,981

Yes, its because find/replace

Read only

0 Likes
3,981


Hi,

I only talked about passing the variable in the 1st perform call. For every perform call, you have to assign actual values to corresponding local variables and then call the form.

Regards,

DPM