Application Development and Automation 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: 
Read only

ABAP 'WITH' Clause

Former Member
0 Likes
826

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
768

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

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

5 REPLIES 5
Read only

Former Member
0 Likes
769

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

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
768

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

Read only

0 Likes
768

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

Read only

Former Member
0 Likes
768

Hi Ian,

Perhaps you can build an macro.

Syntax:

DEFINE macro.

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

END-OF-DEFINITION.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
768

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