on 09-11-2014 5:12 PM
Dear Ladies and Gentlemen,
I have the following problem and would need to help. From an SAP R / 3 I read the following data:
1) Contract number
2) Country
3) Kndenn
Lets say I have now all my data in a ITAB inside Attention now comes my problem:
Customer order Matrial ... ... .. date
entry 1
entry 2
entry 3
entry 4
Now, the data must be processed in the following structure.
Suppose there is a time scale of sy-date-10 days to Sy-date + 20 days so then looks like this:
11.9.2014 | 12.9.2014 | 13.9.2014 | 14.9.2014 | 15.9.2014 | 16.9.2014 | 17.9.2014 | 18.9.2014
Each date (which must be one column which Generic generated by the current SY-date) Horizontol is assigned to a job where the information will then darstehen with each other. So as follows:
11.9.2014 | 12.9.2014 | 13.9.2014 |
Matnr1 Matnr2 Matnr5
Name1 Name2 name5
Date1 Date2 Date5
---------- ------------- -------------
matnr 3 Matnr6
Name 3 Name6
Eckende3 Eckende6
For better visualization, I still have a picture you uploaded where the structure is clear, well-prepared. But now my question is .. how do I use it for? I do not have any idea how can I achieve this and help would be more than grateful!
Hello abdul,
thanks first you helped me a lot of.. but i have problems to understand the * Populate the dynamic table* ... can you explain it a little bit what you are doing there?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you can try this report
*&---------------------------------------------------------------------*
*& Report ZR_ALV_GRID_HOR_DATE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZR_ALV_GRID_HOR_DATE.
TYPE-POOLS : SLIS.
TYPES : BEGIN OF gfirst_typ,
BELNR LIKE BSIK-BELNR,
BLDAT LIKE BSIK-BLDAT,
WRBTR LIKE BSIK-WRBTR,
LIFNR LIKE BSIK-LIFNR.
TYPES : END OF gfirst_typ.
DATA : it_zdemo TYPE TABLE OF gfirst_typ.
DATA : wa_zdemo LIKE LINE OF it_zdemo,
wa_zdemo1 LIKE LINE OF it_zdemo.
DATA : gv_pos TYPE i.
DATA : fname TYPE string.
DATA : sdate TYPE D.
DATA : amt TYPE i.
DATA : amt_chr TYPE C LENGTH 20.
DATA : vendor type BSIK-LIFNR.
DATA : from_date type D.
DATA : tab type c value cl_abap_char_utilities=>CR_LF.
* Parameters
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS so_date FOR sy-datlo OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
INITIALIZATION.
from_date = SY-DATLO - 2.
So_DATE-low = from_date.
So_DATE-high = SY-DATLO.
APPEND so_date.
* Dynamic Table Declarations
DATA : gt_dyn_table TYPE REF TO data,
gw_line TYPE REF TO data,
gw_line1 TYPE REF TO data,
gw_dyn_fcat TYPE lvc_s_fcat,
gt_dyn_fcat TYPE lvc_t_fcat.
* Field Symbols Declarations
FIELD-SYMBOLS: <gfs_line>,<gfs_line1>,
<gfs_dyn_table> TYPE STANDARD TABLE,
<fs1>.
* Populate the initial input table. Usually this input table contents will be populated at run time, which raises the requirement of dynamic table. The table contents are filled here for illustration purpose.
AT SELECTION-SCREEN.
SELECT BELNR BLDAT WRBTR INTO wa_zdemo FROM BSIK
WHERE BLDAT BETWEEN So_DATE-low and so_date-high.
APPEND wa_zdemo TO it_zdemo.
ENDSELECT.
** This would create structure Vendor Jan13 Feb13 Mar13 etc ....
gv_pos = gv_pos + 1.
gw_dyn_fcat-fieldname = 'BELNR'.
gw_dyn_fcat-outputlen = 15.
gw_dyn_fcat-tabname = 'IT_DEMO'.
gw_dyn_fcat-coltext = 'Doc #'.
gw_dyn_fcat-col_pos = gv_pos.
gw_dyn_fcat-key = 'X'.
gw_dyn_fcat-key_sel = 'X'.
APPEND gw_dyn_fcat TO gt_dyn_fcat.
clear gw_dyn_fcat.
* Loop through the internal table creating a column for every distinct month in the internal table
LOOP AT it_zdemo INTO wa_zdemo.
gv_pos = gv_pos + 1.
sdate = wa_zdemo-bldat.
*CONCATENATE sdate INTO fname SEPARATED BY space.
concatenate sdate+6(2) '/' sdate+4(2) '/' sdate(4) into fname.
*fname = sdate.
read table gt_dyn_fcat into gw_dyn_fcat with key fieldname = wa_zdemo-bldat.
if sy-subrc NE 0.
gw_dyn_fcat-fieldname = wa_zdemo-bldat.
gw_dyn_fcat-tabname = 'IT_DEMO'.
gw_dyn_fcat-coltext = fname.
gw_dyn_fcat-outputlen = 60.
gw_dyn_fcat-col_pos = gv_pos.
APPEND gw_dyn_fcat TO gt_dyn_fcat.
endif.
clear gw_dyn_fcat.
ENDLOOP.
** Create a dynamic internal table with this structure.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
i_style_table = 'X'
it_fieldcatalog = gt_dyn_fcat
IMPORTING
ep_table = gt_dyn_table
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc EQ 0.
* Assign the new table to field symbol
ASSIGN gt_dyn_table->* TO <gfs_dyn_table>.
* Create dynamic work area for the dynamic table
CREATE DATA gw_line LIKE LINE OF <gfs_dyn_table>.
CREATE DATA gw_line1 LIKE LINE OF <gfs_dyn_table>.
ASSIGN gw_line->* TO <gfs_line>.
ASSIGN gw_line1->* TO <gfs_line1>.
ENDIF.
* Populate the dynamic table
LOOP AT it_zdemo INTO wa_zdemo.
* Avoid duplicate entries for key field PART.
READ TABLE <gfs_dyn_table> INTO <gfs_line1> WITH KEY ('BELNR') = wa_zdemo-BELNR.
IF sy-subrc = 0.
CONTINUE.
ENDIF.
ASSIGN COMPONENT 'BELNR' OF STRUCTURE <gfs_line> TO <fs1>.
<fs1> = wa_zdemo-belnr.
UNASSIGN <fs1>.
LOOP AT gt_dyn_fcat INTO gw_dyn_fcat.
IF gw_dyn_fcat-fieldname = 'BELNR'.
CONTINUE.
ENDIF.
READ TABLE it_zdemo WITH KEY belnr = wa_zdemo-belnr bldat = gw_dyn_fcat-fieldname INTO wa_zdemo1.
IF sy-subrc = 0.
ASSIGN COMPONENT gw_dyn_fcat-fieldname OF STRUCTURE <gfs_line> TO <fs1>.
*<fs1> = 'Amount:' . wa_zdemo1-wrbtr.
amt_chr = wa_zdemo1-wrbtr.
vendor = wa_zdemo1-lifnr.
CONCATENATE 'Amt: ' amt_chr 'Vendor: ' vendor INTO <fs1> SEPARATED BY tab.
UNASSIGN <fs1>.
ENDIF.
clear : wa_zdemo1.
ENDLOOP.
APPEND <gfs_line> TO <gfs_dyn_table>.
CLEAR: <gfs_line>.
clear: wa_zdemo, wa_zdemo1.
ENDLOOP.
data : gw_alv_fieldcat type slis_fieldcat_alv,
gt_alv_fieldcat type slis_t_fieldcat_alv.
data: lv_pos type i.
loop at gt_dyn_fcat into gw_dyn_fcat.
lv_pos = lv_pos + 1.
gw_alv_fieldcat-fieldname = gw_dyn_fcat-fieldname.
gw_alv_fieldcat-tabname = gw_dyn_fcat-tabname.
gw_alv_fieldcat-seltext_l = gw_dyn_fcat-coltext.
gw_alv_fieldcat-outputlen = gw_dyn_fcat-outputlen.
gw_alv_fieldcat-col_pos = lv_pos.
gw_alv_fieldcat-do_sum = gw_dyn_fcat-do_sum.
gw_alv_fieldcat-emphasize = gw_dyn_fcat-emphasize.
gw_alv_fieldcat-key = gw_dyn_fcat-key.
gw_alv_fieldcat-no_out = gw_dyn_fcat-no_out.
append gw_alv_fieldcat to gt_alv_fieldcat.
endloop.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = sy-repid
it_fieldcat = gt_alv_fieldcat
i_default = 'X'
i_save = 'A'
tables
t_outtab = <gfs_dyn_table>.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.