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

loops in program lines!

Former Member
0 Likes
1,409

Hello all,

I am trying to use loop statement in program lines in a smartform.

Cant I do that?

Thanks,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,365

Yes you can use a loop statement in a program lines node. Are you having a problem? syntax error?

13 REPLIES 13
Read only

abdul_hakim
Active Contributor
0 Likes
1,365

hi somen,

you can only use LOOP for looping thru the internal table contents.

Cheers,

Abdul Hakim

Mark all useful answers..

Read only

Former Member
0 Likes
1,366

Yes you can use a loop statement in a program lines node. Are you having a problem? syntax error?

Read only

0 Likes
1,365

Hello,

Matt and Abdul...thanks for your replies. I am getting this error when I tried the below code in program lines in smartform.

<u>"LS_MAT cannot be converted to line type of GT_MATERIAL"</u>

DATA: ls_mat LIKE gt_material.

  LOOP AT gt_material INTO ls_mat.
    SELECT SINGLE zzcatno FROM mara
      INTO gv_catalog
     WHERE matnr EQ ls_mat-matnr.

    IF sy-subrc = 0.
      EXIT.
    ENDIF.
  ENDLOOP.

GT_MATERIAL is declared in global definition

Message was edited by: Naren Somen

Read only

0 Likes
1,365

Try this

DATA: ls_mat LIKE LINE OF gt_material. If it does not work, let us know the definition of GT_MATERIAL.

Message was edited by: Srinivas Adavi

Read only

0 Likes
1,365

Hi Somen

What is the type of GT_MATERIAL?

Cheers,

Abdul Hakim

Read only

0 Likes
1,365

In TYPES (global definitions) I had defined like this.

types: begin of ty_material,
          matnr type matnr,
       end of ty_material,
       lt_material type table of ty_material,
       ls_material type line of lt_material.

And in GLOBAL DATA I defined like this

GT_MATERIAL	 TYPE	LT_MATERIAL

Thanks,

Read only

0 Likes
1,365

Hi use LS_MAT TYPE TY_MATERIAL.

Cheers,

Abdul

Read only

0 Likes
1,365

You can use

DATA: ls_mat LIKE LINE OF gt_material.

or

DATA: ls_mat LIKE ls_material.

or

DATA: ls_mat TYPE ty_material.

Read only

0 Likes
1,365

Abdul,

I tried but still getting an error.

The error is:

"Field 0 is unknown. It is neither in of the specified tables of declared by 'data' statement"

Thanks,

Read only

0 Likes
1,365

That is completely different issue. Where is it pointing to in your code? I don't see any 0 in your current code.

Read only

0 Likes
1,365

Hi

As srinivas said it is completely a different issue.

jus do syntax check at the global data/type declaration and afterwards do it at the program lines as well.

This is completely a different problem...

Cheers,

Abdul Hakim

Read only

0 Likes
1,365

Thanks for all your replies. My fault. Not because of declarations...old code got disturbed may be due to an accidental key stroke which didnt caught my attention.

Points are awarded as a token of appreciation for your time

Message was edited by: Naren Somen

Read only

0 Likes
1,365

So was that somewhere else? Glad to be of help.