Skip to Content
0

Data required to display differently in columns with Item data

Mar 06 at 08:30 AM

21

avatar image
Former Member

Hi,

I need to display data differently with Item data as columns:


000031 :10:10029 - > On start of every 10 it should be a new line
000031 :15:SD6430
000031 :22:0010/00001 -- > This is Line item
000031 :23:I1712
000031 :31:17122
000031 :41:TR20
000031 :31:171224
000031 :41:8792314
000031 :31:17122
000031 :41:876253
000031 :31:17122
000031 :41:7659
000031 :50:986734
000031 :10:10030 -> On Start of every :10: it should be a new line
000031 :15:SD6432
000031 :22:0010/00002 -- > This is new Line item
000031 :23:I1713
000031 :31:17123
000031 :41:TR21
000031 :50:89324

Any suggestions will be appreciated!

Best Regards,
KC

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Bertrand DELVALLEE Mar 06 at 10:07 AM
1

Hello,

If it's just a matter of display you can use 2 internal tables with a common key

types t_key type char20.
types : begin of tt_header,
k10 type t_key,
k15(20),
k22(20),
k23(20),
k50(20),
begin of t_header.
types : begin of tt_item,
k10 type t_key,
k31(20),
k41(20),
end of t_item.

Then fill these tables :

LOOP AT t_input assigning <input>.
  w_field_type = <input>+10(2). " Or you can use SPLIT or regular expression or ..
  w_field_value = <input>+13. 

  case w_field_type.
  when '10'. 
    APPEND INITIAL LINE TO wt_header ASSIGNING <header>.
    <header>-k10 = w_field_value.
  when '15' or '22' or '23' or '50'. 
    check <header> is assigned.
    concatenate 'k' w_field_type into w_field_name.
    assign (w_field_name) of structure <header> to <field>. 
    <field> = w_field_value.
  when '31'. 
    APPEND INITIAL LINE TO wt_item ASSIGNING <item>.
    <item>-k10 = <header>-k10.
    <item>-k31 = w_field_value.
  when '41'.
    check <item> is assigned.
    <item>-k41 = w_field_value.
  endcase.
ENDLOOP.

Then display using common key

LOOP AT wt_header ASSIGNING <header>.
  WRITE : / <header>-k10, <header>-k15, <header>-k22, <header>-k23.
  READ table wt_item assigning <item> using key k10 = <header>-k10.
  if sy-subrc is initial.
    WRITE : <item>-k31, <item>-k41.
  endif.
  WRITE : <header>-k50.

  LOOP at wt_item assigning <item> where k10 = <header>-k10.
    if sy-tabix > 1. " ignore first line already written
      WRITE : /80(20) <item>-k31, <item>-k41. 
    endif.
  ENDLOOP.
ENDLOOP.

Best regards

Bertrand

Share
10 |10000 characters needed characters left characters exceeded