Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Using field-symbols with FOR ALL ENTRIES IN ...

Hi all of you,

Is it possible to use field symbol by the FOR ALL THE ENTRIES IN itab.

Normally, isn't possible.

So my problem is that I'm having duplicate code.

I've something like this.

      IF ap_objcl EQ omaterial.

        SELECT objectid
        INTO TABLE i_cdpos
        FROM cdpos
        FOR ALL ENTRIES IN otf_materials
        WHERE objectclas = ap_objcl AND
              tabname = otf_materials-tablename AND
              fname = otf_materials-fieldname.
     ELSEIF ap_objcl EQ otf_documents...

And I'm looking to use otf_materials and otf_documents

So, instead to duplicate the code, I'm looking for a way to restrain the code by using maybe field symbols.

Ideal :

FIELD-SYMBOLS : <otf_mats_docs> LIKE OTF_TABLE.

IF ap_objcl EQ omaterial

ASSIGN local copy of otf_materials TO <otf_mats_docs> CASTING.

ELSEIF ap_objcl EQ odocuments

ASSIGN local copy of otf_documents TO <otf_mats_docs> CASTING.

ENDIF.

        SELECT objectid
        INTO TABLE i_cdpos
        FROM cdpos
        FOR ALL ENTRIES IN <otf_mats_docs>
        WHERE objectclas = ap_objcl AND
              tabname = <otf_mats_docs>-tablename AND
              fname = <otf_mats_docs>-fieldname.

 IF ap_objcl EQ omaterials.

*Do nothing

ELSEIF ap_objcl EQ odocuments.

*Do something with the date in otf_documents.
ENDIF.

Regards,

Kais

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question