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

TCD error in Secatt

Former Member
0 Likes
1,474

Hello Gurus,

Below given is my code in Ecatt.

I want to give TCD in loop.But it is not allowing me .Can any one help me in this??

Its urgent

***********************************************************************

ABAP.

*DO COUNT TIMES.

*ABAP BLOCK TO GET THE NUMBER OF TEST CASES

*TOT - HOLDS TOTAL NUMBER OF RECORDS

*FILE- HOLDS FILE PATH OF TEST FILE

DATA:TOT TYPE I VALUE 0,

FILE TYPE STRING.

*ITAB TO HOLD TEST DATA FROM FILE

DATA:BEGIN OF I_LOANFA OCCURS 0,

PERNR LIKE PA0045-PERNR,

BEGDA LIKE PA0045-BEGDA,

ENDDA LIKE PA0045-ENDDA,

EXTDL LIKE PA0045-EXTDL,

DATBW LIKE PA0045-DATBW,

DARBT LIKE PA0045-DARBT,

TILBG LIKE PA0045-TILBG,

TILBT LIKE PA0045-TILBT,

ZAHLD LIKE PA0078-ZAHLD,

ZAHLA LIKE PA0078-ZAHLA,

BETRG LIKE PA0078-BETRG,

END OF I_LOANFA.

*WORK AREA TO HOLD I_LOANFA DATA

DATA:WA LIKE I_LOANFA.

V_FILE-PATH = 'C:\TEST.TXT'.

FILE = V_FILE-PATH.

*LOADING MASTER DATA FROM THE FILE

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = FILE

  • FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = I_LOANFA

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_READ_ERROR = 2

  • NO_BATCH = 3

  • GUI_REFUSE_FILETRANSFER = 4

  • INVALID_TYPE = 5

  • NO_AUTHORITY = 6

  • UNKNOWN_ERROR = 7

  • BAD_DATA_FORMAT = 8

  • HEADER_NOT_ALLOWED = 9

  • SEPARATOR_NOT_ALLOWED = 10

  • HEADER_TOO_LONG = 11

  • UNKNOWN_DP_ERROR = 12

  • ACCESS_DENIED = 13

  • DP_OUT_OF_MEMORY = 14

  • DISK_FULL = 15

  • DP_TIMEOUT = 16

  • OTHERS = 17

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

BREAK-POINT.

*GETTING NUMBER OF RECORDS IN THE TABLE

DESCRIBE TABLE I_LOANFA LINES TOT.

*STORING NUMBER OF RECORDS IN LOCAL VARIABLE

COUNT = TOT.

*CLEARING INTERNAL TABLE

CLEAR I_LOANFA.

  • V_READINDX : holds index number to read the internal table

  • FILE: holds file path of test file

DATA : V_READINDX TYPE I.

DO COUNT TIMES.

V_READINDX = INT_LOC.

READ TABLE I_LOANFA INDEX V_READINDX INTO WA.

*Assigning Work Area Values To The Screen Field Values

V_PERNR = WA-PERNR.

V_BEGDA = WA-BEGDA.

V_ENDDA = WA-ENDDA.

V_EXTDL = WA-EXTDL.

V_DATBW = WA-DATBW.

V_DARBT = WA-DARBT.

V_TILBG = WA-TILBG.

V_TILBT = WA-TILBT.

V_ZAHLD = WA-ZAHLD.

V_ZAHLA = WA-ZAHLA.

V_BETRG = WA-BETRG.

TCD(PA30,PA30_1).

INT_LOC = INT_LOC + 1.

ENDDO.

ENDABAP.

Thanx,

Deepak

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
1,326

Hello Deepak

There are <i>syntactical </i>and <i>logical </i>errors in your eCATT test script.

The logical error is that every eCATT test script should handle a single test case (not multiple at the same time).

However, I admit that there may be situations where we need to handle multiple test cases at the same time.

The syntax error in your test script is that you are mixing eCATT sections with ABAP sections (calling TCD pattern within ABAP...ENDABAP -> not possible).

The correct flow of logic would be :

DO count TIMES.  " ecATT section: begin

  " NOTE: transfer of eCATT variables (import / export) to ABAP (local) required
  ABAP.  " ABAP section: begin
    ...
  ENDABAP.

  TCD(PA30,PA30_1).
  ...

ENDDO.

Regards,

Uwe

Hello Gurus,

Below given is my code in Ecatt.

I want to give TCD in loop.But it is not allowing me .Can any one help me in this??

Its urgent

***********************************************************************

ABAP.

*DO COUNT TIMES.

*ABAP BLOCK TO GET THE NUMBER OF TEST CASES

*TOT - HOLDS TOTAL NUMBER OF RECORDS

*FILE- HOLDS FILE PATH OF TEST FILE

DATA:TOT TYPE I VALUE 0,

FILE TYPE STRING.

*ITAB TO HOLD TEST DATA FROM FILE

DATA:BEGIN OF I_LOANFA OCCURS 0,

PERNR LIKE PA0045-PERNR,

BEGDA LIKE PA0045-BEGDA,

ENDDA LIKE PA0045-ENDDA,

EXTDL LIKE PA0045-EXTDL,

DATBW LIKE PA0045-DATBW,

DARBT LIKE PA0045-DARBT,

TILBG LIKE PA0045-TILBG,

TILBT LIKE PA0045-TILBT,

ZAHLD LIKE PA0078-ZAHLD,

ZAHLA LIKE PA0078-ZAHLA,

BETRG LIKE PA0078-BETRG,

END OF I_LOANFA.

*WORK AREA TO HOLD I_LOANFA DATA

DATA:WA LIKE I_LOANFA.

V_FILE-PATH = 'C:\TEST.TXT'.

FILE = V_FILE-PATH.

*LOADING MASTER DATA FROM THE FILE

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = FILE

  • FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = I_LOANFA

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_READ_ERROR = 2

  • NO_BATCH = 3

  • GUI_REFUSE_FILETRANSFER = 4

  • INVALID_TYPE = 5

  • NO_AUTHORITY = 6

  • UNKNOWN_ERROR = 7

  • BAD_DATA_FORMAT = 8

  • HEADER_NOT_ALLOWED = 9

  • SEPARATOR_NOT_ALLOWED = 10

  • HEADER_TOO_LONG = 11

  • UNKNOWN_DP_ERROR = 12

  • ACCESS_DENIED = 13

  • DP_OUT_OF_MEMORY = 14

  • DISK_FULL = 15

  • DP_TIMEOUT = 16

  • OTHERS = 17

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

BREAK-POINT.

*GETTING NUMBER OF RECORDS IN THE TABLE

DESCRIBE TABLE I_LOANFA LINES TOT.

*STORING NUMBER OF RECORDS IN LOCAL VARIABLE

COUNT = TOT.

*CLEARING INTERNAL TABLE

CLEAR I_LOANFA.

  • V_READINDX : holds index number to read the internal table

  • FILE: holds file path of test file

DATA : V_READINDX TYPE I.

DO COUNT TIMES.

V_READINDX = INT_LOC.

READ TABLE I_LOANFA INDEX V_READINDX INTO WA.

*Assigning Work Area Values To The Screen Field Values

V_PERNR = WA-PERNR.

V_BEGDA = WA-BEGDA.

V_ENDDA = WA-ENDDA.

V_EXTDL = WA-EXTDL.

V_DATBW = WA-DATBW.

V_DARBT = WA-DARBT.

V_TILBG = WA-TILBG.

V_TILBT = WA-TILBT.

V_ZAHLD = WA-ZAHLD.

V_ZAHLA = WA-ZAHLA.

V_BETRG = WA-BETRG.

TCD(PA30,PA30_1).

INT_LOC = INT_LOC + 1.

ENDDO.

ENDABAP.

Thanx,

Deepak

8 REPLIES 8
Read only

uwe_schieferstein
Active Contributor
0 Likes
1,327

Hello Deepak

There are <i>syntactical </i>and <i>logical </i>errors in your eCATT test script.

The logical error is that every eCATT test script should handle a single test case (not multiple at the same time).

However, I admit that there may be situations where we need to handle multiple test cases at the same time.

The syntax error in your test script is that you are mixing eCATT sections with ABAP sections (calling TCD pattern within ABAP...ENDABAP -> not possible).

The correct flow of logic would be :

DO count TIMES.  " ecATT section: begin

  " NOTE: transfer of eCATT variables (import / export) to ABAP (local) required
  ABAP.  " ABAP section: begin
    ...
  ENDABAP.

  TCD(PA30,PA30_1).
  ...

ENDDO.

Regards,

Uwe

Read only

0 Likes
1,326

hello Uwe,

i tried to use code as per your guidance,but it is givin me 2 error:

***************************************************

Parser: COUNT TIMES is not declared

Parser: ENDDO without DO

***************************************************

thanx

Deepak

Read only

0 Likes
1,326

Hello Deepak

Below you can see sample test script <b>ZUS_SDN_ECATT_EXECUTE_FILE </b>which shows you how to organize your script.

ABAP.
* Simulate upload of file with n records
  SELECT * FROM knb1 INTO TABLE lt_knb1 UP TO 20 ROWS.

  DESCRIBE TABLE lt_knb1.
  ld_lines = syst-tfill.

ENDABAP.


ld_idx = 0.

DO ( LD_LINES ).
  ld_idx = ld_idx + 1.

  ABAP.
    READ TABLE lt_knb1 INTO ls_knb1 INDEX ld_idx.
  ENDABAP.

* Move values from LS_KNB1 to single fields for calling TCD
  ld_bukrs = ls_knb1-bukrs.
  ld_kunnr = ls_knb1-kunnr.
* ...

  TCD(VA01, VA01_1).
ENDDO.

Regards

Uwe

Read only

0 Likes
1,326

Hello Deepak

Forgot to mention that you should use the <b>MESSAGE...ENDMESSAGE</b> pattern in order to verify that your transaction has been executed successfully:

MESSAGE ( MSG_1 ).
  TCD(PA30, PA30_1).
ENDMESSAGE ( E_MSG_1 ).

Regards,

Uwe

Read only

0 Likes
1,326

thnx Uwe,

Its working now.But one more i want to know can i use more than 1 recording in one program. i.e. can i use 2 TCD in one program.

THanx

Deepak

Read only

0 Likes
1,326

Hello Deepak

Of course you can use <i>multiple </i>patterns within the same recording, e.g.:


* (1) Create customer
TCD(XD01, XD01_1).

* (2) Create sales order for customer
TCD(VA01, VA01_1).

* (3) Billing of sales order
...

However, you should think about modularization and reusability of your test scripts. Instead of recording multiple transactions (pattern TCD) within the same test script I would recommend another approach:

(1) Create a test script for: "Create customer" (XD01) -> e.g. ZECATT_CREATE_CUSTOMER

(2) Create a test script for: "Create sales order" (VA01) -> e.g. ZECATT_CREATE_SALESORDER

(3) Create a test script for: "Billing sales order" -> e.g. ZECATT_CREATE_BILLINGDOC

(4) Create a "process" test script which refers to the required test scripts, .e.g.:

REF(ZECATT_CREATE_CUSTOMER,...).
REF(ZECATT_CREATE_SALESORDER,...).
REF(ZECATT_CREATE_BILLINGDOC,...).

Regards,

Uwe

Read only

0 Likes
1,326

hello Uwe,

Thanx for your help.

I want to use to use TCD based on some condition i.e. if some condtions satisfy first TCD should run & for some conditon second TCD .Is it possible.

Actually i want to make TCD for Sales Orderin Confirmation of Material in Sceduled Line in batch.

But their can be any number of material,so the confirmation screen can come at any number of times.I have tried to use BDC,LSMW.But nothing work.

In Secatt,i am able to do confrimation,but the number of material is my problem.

So i want to know that based on some condition ican i run TCD.

eg:

if n = 1.

TCD(VA02,VA02_1)

elseif n = 2.

TCD(VA02,VA02_2)

endif.

Or if you have any suggestion please help me in this.

Thanx

Deepak

Read only

0 Likes
1,326

Hello Deepak

I am not a business analyst so I do not really know when the confirmation screen is displayed. However, given your description I assume it is shown after the last order item.

If this assumption is correct then a pseudo-coding would look like:

IF ( n < max. number of items ).
  TCD(VA02,VA02_1).
ELSE.
  TCD(VA02,VA02_2).
ENDIF.

In this case I would call a function module to retrieve the sales order items, determine the number of items and then loop over the items:

" Example: n = 4   => ld_max

  ld_count = ld_max - 1.
  ld_idx = 0.

  DO ( ld_count ).
    ld_idx = ld_idx + 1.

    ABAP.
      READ TABLE lt_items INTO ls_item INDEX ld_idx.
    ENDABAP.

    TCD(VA02,VA02_1).  " transaction without confirmation
  ENDDO.

    ABAP.
      READ TABLE lt_items INTO ls_item INDEX ld_max.
    ENDABAP.  

    TCD(VA02,VA02_2).  " transaction with confirmation

Please note that your TCD recording should handle a <b>single item only</b>. Therefore you somehow need to take care of the selected item number within the transaction.

Regards,

Uwe