‎2006 Jun 09 6:38 PM
Hello all,
I am trying to use loop statement in program lines in a smartform.
Cant I do that?
Thanks,
‎2006 Jun 09 7:12 PM
Yes you can use a loop statement in a program lines node. Are you having a problem? syntax error?
‎2006 Jun 09 6:52 PM
hi somen,
you can only use LOOP for looping thru the internal table contents.
Cheers,
Abdul Hakim
Mark all useful answers..
‎2006 Jun 09 7:12 PM
Yes you can use a loop statement in a program lines node. Are you having a problem? syntax error?
‎2006 Jun 09 7:36 PM
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
‎2006 Jun 09 7:39 PM
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
‎2006 Jun 09 7:42 PM
‎2006 Jun 09 7:49 PM
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_MATERIALThanks,
‎2006 Jun 09 7:52 PM
‎2006 Jun 09 7:56 PM
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.
‎2006 Jun 09 7:57 PM
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,
‎2006 Jun 09 7:59 PM
That is completely different issue. Where is it pointing to in your code? I don't see any 0 in your current code.
‎2006 Jun 09 8:01 PM
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
‎2006 Jun 09 8:25 PM
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
‎2006 Jun 09 8:29 PM