Application Development 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: 

In "LOOP ... WHERE ..." the line type of the table must be statically define

Former Member
0 Kudos

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?

9 REPLIES 9

0 Kudos

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.

thomasnelissen
Participant
0 Kudos

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

custodio_deoliveira
Active Contributor
0 Kudos

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

0 Kudos

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.

ankit_doshi
Participant
0 Kudos

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.

custodio_deoliveira
Active Contributor
0 Kudos

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

matt
Active Contributor
0 Kudos

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:

http://scn.sap.com/people/matthew.billingham/blog/2008/11/08/type-safety--why-should-we-use-types-de...

0 Kudos

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.

matt
Active Contributor
0 Kudos

What's the type of I_propusage?