05-07-2013 10:44 AM
Hi Experts,
I want to use a form to make my program more readable.
But when I move my code into form,error occurs.
SAP shows,In "LOOP ... WHERE ..." the line type of the table must be statically define
FORM print_format tables i_bin
using i_bin-vlpla
i_bin-vistm
itabtra_pul-mblnr
itabtra_pul-mjahr
itabtra_pul-zeile
changing cp06_bin
format_bin.
DATA : char_vistm TYPE char20.
LOOP AT i_bin WHERE mblnr = itabtra_pul-mblnr AND
mjahr = itabtra_pul-mjahr AND
zeile = itabtra_pul-zeile.
WRITE i_bin-vistm TO char_vistm LEFT-JUSTIFIED NO-GROUPING DECIMALS 0.
CONCATENATE i_bin-vlpla '*' char_vistm INTO format_bin.
CONDENSE format_bin NO-GAPS.
IF sy-tabix = 1.
CB_bin = format_bin.
ENDIF.
IF sy-tabix >= 2.
CONCATENATE CB_bin format_bin INTO CB_bin SEPARATED BY '___'.
CONDENSE CB_bin.
ENDIF.
ENDLOOP.
ENDFORM. " Print_Format
Is there any wrong in my code?
05-07-2013 1:35 PM
Hello Jack,
Please create work area of type i_bin and then use it in loop statement.
Ex.
If interna table i_bin has type ty_bin as given below.
data i_bin type standard table of ty_bin.
then in Form print_format, create a work area as given below.
DATA wa_bin type ty_bin.
Then use it in Loop statement as given below.
05-07-2013 1:40 PM
Hi Jack,
Try giving your table a type in the form definition:
FORM print_format tables i_bin TYPE xxx
using i_bin-vlpla
i_bin-vistm
itabtra_pul-mblnr
itabtra_pul-mjahr
itabtra_pul-zeile
changing cp06_bin
format_bin.
Best regards,
Thomas
05-07-2013 1:41 PM
HiJack,
Not sure this is "the" problem, but maybe you should loop ... into workarea?
data ls_bin type XXXX "define the line type here
LOOP AT i_bin into ls_bin
WHERE mblnr = itabtra_pul-mblnr AND
mjahr = itabtra_pul-mjahr AND
zeile = itabtra_pul-zeile.
Cheers,
Custodio
05-07-2013 1:50 PM
Yes, he should. Tables with header line are obsolete because they're ambiguous. Don't use them - use tables without header-lines, with a separately defined work area. If you've already got a table with a header line - use a work area anyway - it's better programming.
05-07-2013 1:43 PM
Hi,
Please define types along with the parameters in the form routine and also check the order of USING CHANGING and TABLES.
e.g. i_bin TYPE TABLE OF xyz.
05-07-2013 1:45 PM
Actually, the problem is that you need to declare the structure of the table in the form:
FORM print_format tables i_bin STRUCTURE XXXXX
using i_bin-vlpla
i_bin-vistm
itabtra_pul-mblnr
itabtra_pul-mjahr
itabtra_pul-zeile
changing cp06_bin
format_bin.
Cheers,
Custodio
05-07-2013 1:51 PM
As already noted, you're using a table with a header line, which, while syntactically correct, is not good programming. As far as the typing of your FORM goes, the above posters are correct. You must type the parameters. If you want to be a better programmer and understand why you should do this, may I refer you to my blog from a few years ago:
07-02-2013 2:43 PM
Hi Matthew,
I am making use of the following code .
PERFORM duty_band_pro TABLES I_PROPUSAGE
I_PROPDATA
EX_MSG_TAB
R_LVAL_AREA
CHANGING EX_MVGR3 .
FORM DUTY_BAND_PRO TABLES P_I_PROPUSAGE LIKE I_PROPUSAGE
P_I_PROPDATA LIKE I_PROPDATA
P_EX_MSG_TAB TYPE ZI_MSG_TAB
P_R_LVAL_AREA TYPE STANDARD TABLE SELOPT
CHANGING P_EX_MVGR3 TYPE ZFIELD_VALUE.
LOOP AT P_I_PROPUSAGE ASSIGNING <FS_PROPUSAGE>
WHERE VAL_AREA IN P_R_LVAL_AREA.
here in this loop i am getting the error stating "In "LOOP ... WHERE ..." the line type of the table must be statically defined"
regards,
ranjith.
07-02-2013 5:13 PM