Skip to Content
author's profile photo Former Member
Former Member

ABAP 'WITH' Clause

Does ABAP have something like a WITH clause?

Other languages allow me to something like ...

WITH myrec DO

{do some processing}

ENDWITH

I find that I am ...

wa-field1 = 'newdata1'.

wa-field1 = 'newdata2'.

...

wa-field99 = 'newdata99'.

... seems very labourious

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 08:35 PM

    HI,

    Welcome to SDN...

    I dont believe that ABAP has <b>WITH</b> Clause...

    ABAP Have some of below clauses...

    <b>SELECT

    ENDSELECT

    INTO

    WHERE

    HAVING

    ORDER-BY

    GROUP-BY

    FROM</b>

    u can also use loops like...

    <b>DO...ENDDO.

    WHILE....ENDWHILE.

    LOOP....ENDLOOP.</b>

    Regards

    CNU

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 10, 2007 at 08:39 PM

    Nothing like that, but of cousre your requirement can be done in ABAP other ways. For example, If you want to dynamically fill a field, you can use the ASSIGN COMPONENT statement. I would really have to understand your required in order to point you in the right direction. Can you explain a bit more?

    Regards,

    Rich HEilman

    Add a comment
    10|10000 characters needed characters exceeded

    • For example.........

      
      report zrich_0001.
      
      data: begin of xstruc,
            fld1(10) type c,
            fld2(10) type c,
            fld3(10) type c,
            fld4(10) type c,
            fld5(10) type c,
            end of xstruc.
      
      data: istr type table of string with header line.
      field-symbols: <fs> .
      
      istr = 'Value A'.  append istr.
      istr = 'Value B'.  append istr.
      istr = 'Value C'.  append istr.
      istr = 'Value D'.  append istr.
      istr = 'Value E'.  append istr.
      
      
      loop at istr.
      
        assign component sy-tabix of structure xstruc to <fs>.
        if sy-subrc <> 0.
          exit.
        endif.
      
        <fs> = istr.
      
      
      endloop.
      
      
      write:/ xstruc-fld1,
              xstruc-fld2,
              xstruc-fld3,
              xstruc-fld4,
              xstruc-fld5.
      
      

      Regards,

      Rich Heilman

  • Posted on Jan 10, 2007 at 08:43 PM

    Hi Ian,

    Perhaps you can build an macro.

    Syntax:

    DEFINE macro.

    ... &1 ... &9 ...

    END-OF-DEFINITION.

    Regards,

    Ferry Lianto

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 08:56 PM

    So far things look like this

    data: itab type table of t_itab,

    w_itab type t_itab.

    w_itab-tabname = 'Tablename'.

    w_itab-position = 'Pos'.

    ...

    append w_itab to itab.

    whereas it might read ...

    with w_itab do

    tabname = 'Tablename'.

    position = 'Pos'.

    endwith

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.