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

Format for fields in an internal table

Former Member
0 Likes
448

DATA: BEGIN OF ITAB OCCURS 0,

AUFNR LIKE AFKO-AUFNR, " Purchase Order Number

PLNBEZ LIKE AFKO-PLNBEZ, " Part Number

BISMT like MARA-BISMT, " Old Material

LNO(2),

GAMNG LIKE AFKO-GAMNG, " Production Order Quantity

GLTRP LIKE AFKO-GLTRP,

VDATU LIKE VBAK-VDATU,

KWMENG LIKE VBAP-KWMENG,

MBDAT LIKE VBEP-MBDAT,

GBSTA LIKE VBUK-GBSTK,

PCTBS(5),

*CSHOT

  • "CDESC

END OF ITAB.

LOOP AT ITAB.

WRITE:/3 ITAB-AUFNR,

13 ITAB-PLNBEZ,

23 ITAB-BISMT,

  • LNO(2),

45 ITAB-GAMNG,

65 ITAB-GLTRP.

  • 57 ITAB-VDATU.

  • *63 ITAB-KWMENG,

  • 69 ITAB-MBDAT.

  • PCTBS(5),

*C

ENDLOOP.

I have a internal table and I have writing the itab in the write statement. I need to format the field in itab.

for eg:

itab-gamng(lenght as 5)

itab-gltrp(its a date) i just need the mm/yy how can I format it.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
408

You don' need to reformat the itab, just the fields before you write them.



<b>data: monthyear(5) type c.
data: qty(5) type c.</b>


LOOP AT ITAB.


<b>concatenate itab-gltrp+4(2) '/'
            itab-gltrp+0(4) 
                    into monthyear.

clear qty.
qty = qty + itab-gamng.</b>

WRITE:/3 ITAB-AUFNR,
13 ITAB-PLNBEZ,
23 ITAB-BISMT,
* LNO(2),
<b>*45 ITAB-GAMNG,
  45 qty,
* 65 ITAB-GLTRP.
  65 monthyear.</b>
* 57 ITAB-VDATU.
* *63 ITAB-KWMENG,
* 69 ITAB-MBDAT.
* PCTBS(5),
*C
ENDLOOP.


Regards,

Rich Heilman

DATA: BEGIN OF ITAB OCCURS 0,

AUFNR LIKE AFKO-AUFNR, " Purchase Order Number

PLNBEZ LIKE AFKO-PLNBEZ, " Part Number

BISMT like MARA-BISMT, " Old Material

LNO(2),

GAMNG LIKE AFKO-GAMNG, " Production Order Quantity

GLTRP LIKE AFKO-GLTRP,

VDATU LIKE VBAK-VDATU,

KWMENG LIKE VBAP-KWMENG,

MBDAT LIKE VBEP-MBDAT,

GBSTA LIKE VBUK-GBSTK,

PCTBS(5),

*CSHOT

  • "CDESC

END OF ITAB.

LOOP AT ITAB.

WRITE:/3 ITAB-AUFNR,

13 ITAB-PLNBEZ,

23 ITAB-BISMT,

  • LNO(2),

45 ITAB-GAMNG,

65 ITAB-GLTRP.

  • 57 ITAB-VDATU.

  • *63 ITAB-KWMENG,

  • 69 ITAB-MBDAT.

  • PCTBS(5),

*C

ENDLOOP.

I have a internal table and I have writing the itab in the write statement. I need to format the field in itab.

for eg:

itab-gamng(lenght as 5)

itab-gltrp(its a date) i just need the mm/yy how can I format it.

1 REPLY 1
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
409

You don' need to reformat the itab, just the fields before you write them.



<b>data: monthyear(5) type c.
data: qty(5) type c.</b>


LOOP AT ITAB.


<b>concatenate itab-gltrp+4(2) '/'
            itab-gltrp+0(4) 
                    into monthyear.

clear qty.
qty = qty + itab-gamng.</b>

WRITE:/3 ITAB-AUFNR,
13 ITAB-PLNBEZ,
23 ITAB-BISMT,
* LNO(2),
<b>*45 ITAB-GAMNG,
  45 qty,
* 65 ITAB-GLTRP.
  65 monthyear.</b>
* 57 ITAB-VDATU.
* *63 ITAB-KWMENG,
* 69 ITAB-MBDAT.
* PCTBS(5),
*C
ENDLOOP.


Regards,

Rich Heilman