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

PR - Multiple Line Item

Former Member
0 Likes
2,256

Hi Experts,

I am new to Ecatt.

I am creating the Test Script for a PR (ME51N) creation. I was sucessfully done for the single line item, but i was strucked when there is more line items. Experts, i need your guidance for proceeding. I recorded by creating the single line item. I have wrote the code as like as below and i careated a file with the 2 line items but the script created the 2 PR's with each line item. But still am unable to achieve the Mutli line item PR. Please let me know how to proceed further.

ABAP.

DATA: V_TOT TYPE I VALUE 0,

V_FILE TYPE STRING.

TYPES: BEGIN OF TY_STRUC,

V_KNTTP TYPE EBAN-KNTTP,

V_TXZ01 TYPE EBAN-TXZ01,

V_MENGE TYPE EBAN-MENGE,

V_MEINS TYPE EBAN-MEINS,

V_MATKL TYPE EBAN-MATKL,

V_NAME1 TYPE ADDR1_DATA-NAME1,

V_EKGRP TYPE EBAN-EKGRP,

V_AFNAM TYPE EBAN-AFNAM,

V_PREIS TYPE EBAN-PREIS,

V_EKORG TYPE EBAN-EKORG,

V_SAKTO TYPE MSEG-SAKTO,

V_KOSTL TYPE CBPR-KOSTL,

END OF TY_STRUC.

DATA: IT_STRUC TYPE TABLE OF TY_STRUC.

CONSTANTS: C_X(01) TYPE C VALUE 'X',

C_FILE TYPE DYNPREAD-FIELDNAME VALUE 'FILE'.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

FIELD_NAME = C_FILE

IMPORTING

FILE_NAME = FILE_V-PATH.

V_FILE = FILE_V-PATH.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = V_FILE

HAS_FIELD_SEPARATOR = C_X

TABLES

DATA_TAB = IT_STRUC.

DESCRIBE TABLE IT_STRUC LINES V_TOT.

COUNT = V_TOT.

FREE IT_STRUC.

ENDABAP.

DO (COUNT).

ABAP.

DATA : V_READINDX TYPE I,

V_FILE TYPE STRING,

INDX TYPE I VALUE 0.

TYPES: BEGIN OF TY_STRUC,

V_KNTTP TYPE EBAN-KNTTP,

V_TXZ01 TYPE EBAN-TXZ01,

V_MENGE TYPE EBAN-MENGE,

V_MEINS TYPE EBAN-MEINS,

V_MATKL TYPE EBAN-MATKL,

V_NAME1 TYPE ADDR1_DATA-NAME1,

V_EKGRP TYPE EBAN-EKGRP,

V_AFNAM TYPE EBAN-AFNAM,

V_PREIS TYPE EBAN-PREIS,

V_EKORG TYPE EBAN-EKORG,

V_SAKTO TYPE MSEG-SAKTO,

V_KOSTL TYPE CBPR-KOSTL,

END OF TY_STRUC.

DATA: IT_STRUC TYPE TABLE OF TY_STRUC,

WA_STRUC TYPE TY_STRUC.

V_FILE = FILE_V-PATH.

CONSTANTS: C_X(01) TYPE C VALUE 'X'.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = V_FILE

HAS_FIELD_SEPARATOR = C_X

TABLES

DATA_TAB = IT_STRUC.

V_READINDX = INT_LOC.

READ TABLE IT_STRUC INDEX V_READINDX INTO WA_STRUC.

V_KNTTP = WA_STRUC-V_KNTTP.

V_TXZ01 = WA_STRUC-V_TXZ01.

V_MENGE = WA_STRUC-V_MENGE.

V_MEINS = WA_STRUC-V_MEINS.

V_MATKL = WA_STRUC-V_MATKL.

V_NAME1 = WA_STRUC-V_NAME1.

V_EKGRP = WA_STRUC-V_EKGRP.

V_AFNAM = WA_STRUC-V_AFNAM.

V_PREIS = WA_STRUC-V_PREIS.

V_EKORG = WA_STRUC-V_EKORG.

V_SAKTO = WA_STRUC-V_SAKTO.

V_KOSTL = WA_STRUC-V_KOSTL.

ENDABAP.

TCD ( ME51N , ME51N_1 ).

INT_LOC = INT_LOC + 1.

ENDDO.

13 REPLIES 13
Read only

Former Member
0 Likes
1,950

Srikag,

Review the posts in the below link where I have suggested to use SAPGUI recording and parametrized the variable within the loop. You can try similar changes in your TCD recording to see if it works, if not you can record PR creation for 1 line item and change the script for multiple line items.

Let me know if you have any issues.

thanks

Venkat

Read only

0 Likes
1,950

Thank you so much for your reply...

if not you can record PR creation for 1 line item and change the script for multiple line items.

I recorded by using TCD only for one line item and please kindly me know how to change the script for multiple line items.

Thanks,

Srikag

Edited by: SRIKAG on Nov 23, 2010 4:06 AM

Read only

0 Likes
1,950

Hi Venkat,

I am reading a thread in that they mentioned as "Create a structure parameter to pass more than one line item."

How to create the structure parameter in the ecatt to pass the multiple lines. I am having a import parameter as

v_txz01

v_menge

v_meins

v_sakto like this as reference as BDC_FVAL. Structure parameter is like as v_txz01[]

v_menge[] we need to create as like this or there is anyother way to do this. Please guide me.

Read only

0 Likes
1,950

Yes, you are correct. You need to create a import parameter name as per your requirement (like v_menge or v_meins). Instead of using the reference as BDC_VAL you need to use the proper reference for those fields as below

Parameter name Reference field

V_MENGE MENGE[]

V_MEINS MEINS[]

You can use this parameter name V_MENGE to use in your script to pass the values. Since this is the structure parameter you have to use this field in the script as V_MENGE[&LPC]-TABLE_LINE. I assume your recording within the DO.... ENDDO.

&LPC should be within the squarebrackets []. &LPC is the eCatt keyword for the counter values within the loop. First time when he control enters the DO.. ENDDO the &LPC will have value 1 and so on...

Table_line is also the keyword that referring the structure parameter fields.

Let me know if you still have questions or issues.

thanks

Venkat

Read only

0 Likes
1,950

Thank you for your reply....

U r saying that we need to use the field as V_MENGE[&LPC]-TABLE_LINE. I am having one query that we need to use this in the ABAP CODE or in the 'VALIN' field in the script where we are passing the field.

I am keeping the Test script between the Do and Endo only... please kindly see my code below... Please guide me if i am wrong...

&lpc is in Brackets only... [ ].

DO (COUNT).

READ TABLE IT_STRUC INDEX V_READINDX INTO WA_STRUC.

V_KNTTP[&LPC]-TABLE_LINE = WA_STRUC-V_KNTTP.

V_TXZ01[&LPC]-TABLE_LINE = WA_STRUC-V_TXZ01.

V_MENGE[&LPC]-TABLE_LINE = WA_STRUC-V_MENGE.

V_MEINS[&LPC]-TABLE_LINE = WA_STRUC-V_MEINS.

V_MATKL[&LPC]-TABLE_LINE = WA_STRUC-V_MATKL.

V_NAME1[&LPC]-TABLE_LINE = WA_STRUC-V_NAME1.

V_EKGRP[&LPC]-TABLE_LINE = WA_STRUC-V_EKGRP.

V_AFNAM[&LPC]-TABLE_LINE = WA_STRUC-V_AFNAM.

V_PREIS[&LPC]-TABLE_LINE = WA_STRUC-V_PREIS.

V_EKORG[&LPC]-TABLE_LINE = WA_STRUC-V_EKORG.

V_SAKTO[&LPC]-TABLE_LINE = WA_STRUC-V_SAKTO.

V_KOSTL[&LPC]-TABLE_LINE = WA_STRUC-V_KOSTL.

ENDABAP.

TCD ( ME51N , ME51N_1 ).

INT_LOC = INT_LOC + 1.

ENDDO.

Thanks,

Srikag

Edited by: SRIKAG on Nov 23, 2010 5:28 PM

Read only

0 Likes
1,950

you need to pass that value in the VALIN field as *V_KNTTP[&LPC]-table_line.

If you get any error on this line V_KNTTP&LPC-TABLE_LINE = WA_STRUC-V_KNTTP. then you can try as V_KNTTP[] = WA_STRUC-V_KNTTP within the ABAP ... ENDABAP.

thanks

Venkat

Read only

0 Likes
1,950

Hi Venkat,

I changed the parameter reference as MENGE[] after that i didn't get the value's in ABAP TYPE (TAB) and LENGTH(TAB) its blank . In the VALUE tab i am getting as <INITIAL>. While executing its not taking the data from the flat file instead of that its taking as <INITIAL>.

In VALIN i changed the variable as v_menge[&LPC]-TABLE_LINE. I am getting the error as v_menge is not defined. How can i proceed further.

After changing the VALIN as below i am getting the error as below.

Reference V_NAME1[ &lpc ]-TABLE_LINE for ME51N_1-DYNPRO[18]-FIELD[44]-

VALIN Is Not Defined as an eCATT Parameter.

I declared(V_NAME1[ &lpc ]-TABLE_LINE ) the same in the Parameter field.

Please guide me for further proceedings....

Thanks,

Srikag

Edited by: SRIKAG on Nov 24, 2010 3:26 PM

Read only

0 Likes
1,950

1. As far as you are getting the <Initia> in the value and blank in ABAP TYPE (TAB) and LENGTH(TAB) is correct since this is the structure parameter.

2. Check the import parameter name in the parameter list and use the same in the interface (VALIN). The &LPC should be in [] when you pass to the interface.

3. Your interface should be inside the DO... ENDDO

4. You have to declare the field name as V_NAME1 and type the reference field as NAME[]

5. In the interface for the field VALIN only you have to use V_NAME1 &lpc -TABLE_LINE.

6. Table_line keyword should not be in the parameter window.

Verify the above for all the fields and hope you should be able to resolve your issue.

let me know if you still have any issues.

thanks

Venkat

Read only

0 Likes
1,950

Hi Venkat,

2. Check the import parameter name in the parameter list and use the same in the interface (VALIN). The &LPC should be in [] when you pass to the interface.

You are saying that we need to create the Parameter as V_NAME[&LPC], &LPC in [ ] while giving as like this i am getting the error message has 'Only characters and '_' . So what can i do in this case... Parameter : V_NAME[&LPC] and the parameter ref as NAME[ ] right. I am not able to use the square brackets while i am creating the parameter as well as in the VALIN.

4. You have to declare the field name as V_NAME1 and type the reference field as NAME[]

I am very sorry that i am unable to understand the above statement, Where we need to declare the above statement in the parameter or in the ABAP code, as per my understanding you are saying that in the parameters right. Why we need to declare this already we declared the import parameter right.

5. In the interface for the field VALIN only you have to use V_NAME1 &lpc -TABLE_LINE.

While i am declaring as above in the valin i am getting the error message as 'No [], & not allowed'.

Please let me know...

Read only

0 Likes
1,950

Srikag,

Sorry If I confused you. Here is the answers. Hope this is clear.

1. Check the import parameter name in the parameter list and use the same in the interface (VALIN). The &LPC should be in [] when you pass to the interface.

I was trying to say that we need to create the import variables like V_NAME1 or V_MEINS and give the proper reference data element like MEINS with square brackets to use as structure parameter. The import variable NAME should NOT have the special characters like & or [] . The & or the square brackets should only be in the VALIN field.

Check all your import parameters in the parameter to make sure it is ok as I said above.

4. You have to declare the field name as V_NAME1 and type the reference field as NAME[]

It is the same as above in # 1.

Thanks

Venkat

Read only

0 Likes
1,950

Thanks for your reply...

While i am follwing your Instruction i am getting the error message as "Reference V_TXZ01[&LPC]-TABLE_LINE for ME51N_1-DYNPRO[4]-FIELD[40]-VALIN Is Not Defined as an eCATT Parameter". But i defined the parameter as V_TXZ01 and the reference as *TXZ01[ ] *. In the VALIN i am passing V_TXZ01[&LPC]-TABLE_LINE LPC in the Square brackets. Please help me out to finsh this task.

Thanks,

Srikag

Read only

0 Likes
1,950

Srikag,

Are you getting this error message for all the parameters that you declared as structure parameter?. I tried with some sample script using this field and assigned in the valin like you did, I didn't get any error message.

Please check the field once again and you parameter declaration to make sure it is correct.

thanks

Venkat

Read only

0 Likes
1,950

Venkat,

The issue has been resolved by myself, using the SAP GUI recording instead of passing the &LPC-TABLE_LINE i declared the parameter for incrementing the index and i am passing the same in the index parameter in the Interface. So issue has been resolved. Thanks alot for your guidance venkat.

This is working fine for one account assignment and now there is another need i need to do the same for all the account assignments. I need to know that whether i need to create the 4 different scripts for different assignments or its possible to do the same in this script. Please guide me...

Thanks,

Srikag