2006 Jun 22 9:46 AM
have this alv
MATNR LABST INSME LGORT
1234 3 0 001
1234 2 2 002
1234 1 1 003
I WANT THE ALV LOOKS LIKE THIS
MATNR LGORT(001)/LABST LGORT(002)/LABST LGORT(003)/LABST
1234 3 2 1
EVERTHING IN THE SAME LINE AND LGORT AT THE TOP
AND IT'S DYNAMIC
the dymnaic table didnt help me sorry
have this alv
MATNR LABST INSME LGORT
1234 3 0 001
1234 2 2 002
1234 1 1 003
I WANT THE ALV LOOKS LIKE THIS
MATNR LGORT(001)/LABST LGORT(002)/LABST LGORT(003)/LABST
1234 3 2 1
EVERTHING IN THE SAME LINE AND LGORT AT THE TOP
AND IT'S DYNAMIC
the dymnaic table didnt help me sorry
2006 Jun 22 11:27 AM
2006 Jun 22 3:30 PM
2006 Jun 22 3:35 PM
why dont you try Creating a ALV Tree Hierarchy ?
Alejandro Garaban
2006 Jun 22 6:52 PM
2006 Jun 22 7:27 PM
HI Rani,
check this example prg of ALV hierarchy
report zxx_alvexer message-id zz .
&----
*& TABLES DECLARATION *
&----
tables: vbak, vbap.
&----
*& TYPE POOLS DECLARATION *
&----
type-pools: slis.
----
DATA DECLARATIONS *
----
data: v_flag type c. "Flag to display the header
data: v_repid type sy-repid.
&----
*& INTERNAL TABLE DECLARATION *
&----
data: begin of it_vbak occurs 0,
vbeln like vbak-vbeln,
audat like vbak-audat,
auart like vbak-auart,
netwr like vbak-netwr,
expand(1),
end of it_vbak.
data: begin of it_vbap occurs 0,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
matnr like vbap-matnr,
pstyv like vbap-pstyv,
charg like vbap-charg,
end of it_vbap.
data: it_fldcat type slis_t_fieldcat_alv,
it_fldcat1 type slis_t_fieldcat_alv,
*events
it_events type slis_t_event with header line,
v_call type c,
x_user type slis_exit_by_user,
it_variant like disvariant occurs 0 with header line,
x_keyinfo type slis_keyinfo_alv,
*layout
x_layout type slis_layout_alv,
*sort
it_sort type slis_t_sortinfo_alv,
wa_sort like line of it_sort,
x_cat type slis_fieldcat_alv,
v_tabix like sy-tabix.
----
Selection screen Declaration
----
*--BLOCK1
selection-screen begin of block b1 with frame title text-001.
select-options: s_vbeln for vbak-vbeln,
s_auart for vbak-auart.
selection-screen end of block b1.
----
AT SELECTION-SCREEN *
----
*- Validations
at selection-screen.
perform validate_screen.
----
START OF SELECTION *
----
start-of-selection.
*- To get data from VBAK
perform get_data.
*to get data from VBAP
perform get_data_vbap.
perform prepare_alv.
----
END OF SELECTION *
----
end-of-selection.
perform display_report.
&----
*& Form VALIDATE_SCREEN
&----
text
----
--> p1 text
<-- p2 text
----
form validate_screen .
data: lv_vbeln like vbak-vbeln,
lv_auart like vbak-auart.
if not s_vbeln[] is initial.
select vbeln
into lv_vbeln
from vbak
where vbeln in s_vbeln.
endselect.
if sy-subrc <> 0.
message e000 with 'INVALID SALES DOC'(002).
endif.
endif.
if not s_auart[] is initial.
select auart
into lv_auart
from vbak
where auart in s_auart.
endselect.
if sy-subrc <> 0.
message e000 with 'INVALID SALES DOC TYPE'(003).
endif.
endif.
endform. " VALIDATE_SCREEN
&----
*& Form GET_DATA
&----
text
----
--> p1 text
<-- p2 text
----
form get_data .
select vbeln
audat
auart
netwr
from vbak
into table it_vbak
where vbeln in s_vbeln
and auart in s_auart.
if sy-subrc = 0.
sort it_vbak by vbeln.
endif.
endform. " GET_DATA
&----
*& Form GET_DATA_VBAP
&----
text
----
--> p1 text
<-- p2 text
----
form get_data_vbap .
select vbeln
posnr
matnr
pstyv
charg
into table it_vbap
from vbap
for all entries in it_vbak
where vbeln = it_vbak-vbeln.
if sy-subrc = 0.
sort it_vbap by vbeln posnr.
endif.
endform. " GET_DATA_VBAP
&----
*& Form prepare_alv
&----
text
----
--> p1 text
<-- p2 text
----
form prepare_alv .
Prepare field catalog .
perform prepare_catalog.
Modify catalog
perform change_attr_of_catalog.
Modify Layout
perform modify_layout.
Sort Catalog
perform sort_catalog.
endform. " prepare_alv
&----
*& Form prepare_catalog
&----
text
----
--> p1 text
<-- p2 text
----
form prepare_catalog .
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = sy-repid
i_internal_tabname = 'IT_VBAK'
i_inclname = sy-repid
changing
ct_fieldcat = it_fldcat1[]
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
append lines of it_fldcat1 to it_fldcat.
clear: it_fldcat1[].
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = sy-repid
i_internal_tabname = 'IT_VBAP'
i_inclname = sy-repid
changing
ct_fieldcat = it_fldcat1[]
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
append lines of it_fldcat1 to it_fldcat.
endform. " prepare_catalog
&----
*& Form change_attr_of_catalog
&----
text
----
--> p1 text
<-- p2 text
----
form change_attr_of_catalog .
loop at it_fldcat into x_cat.
v_tabix = sy-tabix.
case x_cat-fieldname.
when 'EXPAND'.
if x_cat-tabname = 'IT_VBAK'.
x_cat-no_out = 'X'.
endif.
when 'VBELN'.
if x_cat-tabname = 'IT_VBAK'.
x_cat-no_out = 'X'.
endif.
when 'VBELN'.
if x_cat-tabname = 'IT_VBAK'.
x_cat-col_pos = '1'.
x_cat-seltext_m = 'SALES DOC'.
x_cat-seltext_l = 'SALES DOC'.
x_cat-seltext_s = 'SALES DOC'.
x_cat-outputlen = '10'.
endif.
when 'AUDAT'.
if x_cat-tabname = 'IT_VBAK'.
x_cat-col_pos = '2'.
x_cat-seltext_m = 'DOC DATE'.
x_cat-seltext_l = 'DOC DATE'.
x_cat-seltext_s = 'DOC DATE'.
x_cat-outputlen = '8'.
endif.
when 'AUART'.
if x_cat-tabname = 'IT_VBAK'.
x_cat-col_pos = '3'.
x_cat-seltext_m = 'ORDER REASON'.
x_cat-seltext_l = 'ORDER REASON'.
x_cat-seltext_s = 'ORDER REASON'.
x_cat-outputlen = '5'.
endif.
when 'NETWR'.
if x_cat-tabname = 'IT_VBAK'.
x_cat-col_pos = '4'.
x_cat-seltext_m = 'NET PRICE'.
x_cat-seltext_l = 'NET PRICE'.
x_cat-seltext_s = 'NET PRICE'.
x_cat-outputlen = '15'.
endif.
endcase.
modify it_fldcat from x_cat.
clear x_cat.
endloop.
endform. " change_attr_of_catalog
&----
*& Form modify_layout
&----
text
----
--> p1 text
<-- p2 text
----
form modify_layout .
x_layout-default_item = 'X'.
x_layout-zebra = 'X'.
x_layout-expand_fieldname = 'EXPAND'.
endform. " modify_layout
&----
*& Form sort_catalog
&----
text
----
--> p1 text
<-- p2 text
----
form sort_catalog .
clear wa_sort.
wa_sort-spos = '01'.
wa_sort-fieldname = 'VBELN' .
wa_sort-tabname = 'IT_VBAP'.
wa_sort-up = 'X'.
append wa_sort to it_sort.
clear wa_sort.
wa_sort-spos = '02'.
wa_sort-fieldname = 'POSNR' .
wa_sort-tabname = 'IT_VBAP'.
wa_sort-up = 'X'.
append wa_sort to it_sort.
endform. " sort_catalog
&----
*& Form DISPLAY_REPORT
&----
text
----
--> p1 text
<-- p2 text
----
form display_report .
it_variant-report = sy-repid.
sort it_vbak by vbeln.
sort it_vbap by vbeln posnr.
call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
exporting
i_callback_program = sy-repid
is_layout = x_layout
it_fieldcat = it_fldcat[]
it_sort = it_sort
is_variant = it_variant
it_events = it_events[]
i_tabname_header = 'IT_VBAK'
i_tabname_item = 'IT_VBAP'
is_keyinfo = x_keyinfo
importing
e_exit_caused_by_caller = v_call
es_exit_caused_by_user = x_user
tables
t_outtab_header = it_vbak
t_outtab_item = it_vbap
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " DISPLAY_REPORT
Regards,
Laxmi.
2006 Jun 22 8:57 PM
How about this......
report zrich_0001.
type-pools: slis.
field-symbols: <dyn_table> type standard table,
<dyn_wa>.
data: alv_fldcat type slis_t_fieldcat_alv,
it_fldcat type lvc_t_fcat,
wa_it_fldcat type lvc_s_fcat.
data: imard type table of mard with header line.
selection-screen begin of block b1 with frame title text-001.
parameters: p_matnr type mard-matnr.
parameters: p_werks type mard-werks.
selection-screen end of block b1.
start-of-selection.
select * into table imard from mard
where matnr = p_matnr
and werks = p_werks.
* build the dynamic internal table
perform build_dyn_itab.
perform build_report.
* call the alv grid.
perform call_alv.
************************************************************************
* Build_dyn_itab
************************************************************************
form build_dyn_itab.
data: new_table type ref to data,
new_line type ref to data,
tot_lines type i.
clear wa_it_fldcat.
wa_it_fldcat-fieldname = 'MATNR'.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-seltext = 'Material Number'.
wa_it_fldcat-intlen = 18.
append wa_it_fldcat to it_fldcat .
clear wa_it_fldcat.
wa_it_fldcat-fieldname = 'WERKS'.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-seltext = 'Plant'.
wa_it_fldcat-intlen = 4.
append wa_it_fldcat to it_fldcat .
loop at imard.
clear wa_it_fldcat.
concatenate 'LGORT' imard-lgort into
wa_it_fldcat-fieldname.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-seltext = wa_it_fldcat-fieldname.
wa_it_fldcat-intlen = 4.
append wa_it_fldcat to it_fldcat .
clear wa_it_fldcat.
concatenate 'LABST' imard-lgort into
wa_it_fldcat-fieldname.
wa_it_fldcat-datatype = 'QUAN'.
wa_it_fldcat-seltext = wa_it_fldcat-fieldname.
wa_it_fldcat-intlen = 15.
append wa_it_fldcat to it_fldcat .
endloop.
* Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fldcat
importing
ep_table = new_table.
assign new_table->* to <dyn_table>.
* Create dynamic work area and assign to FS
create data new_line like line of <dyn_table>.
assign new_line->* to <dyn_wa>.
endform.
*********************************************************************
* Form build_report
*********************************************************************
form build_report.
data: fieldname(20) type c.
data: fieldvalue(5) type c.
data: index(3) type c.
field-symbols: <fs1>.
assign component 'MATNR' of structure <dyn_wa> to <fs1>.
<fs1> = p_matnr.
assign component 'WERKS' of structure <dyn_wa> to <fs1>.
<fs1> = p_werks.
loop at imard.
index = sy-index.
* Set the LGORT
concatenate 'LGORT' imard-lgort into
fieldname.
condense fieldname no-gaps.
assign component fieldname of structure <dyn_wa> to <fs1>.
<fs1> = imard-lgort.
* Set the LABST
concatenate 'LABST' imard-lgort into
fieldname.
condense fieldname no-gaps.
assign component fieldname of structure <dyn_wa> to <fs1>.
<fs1> = imard-labst.
endloop.
* Append to the dynamic internal table
append <dyn_wa> to <dyn_table>.
endform.
************************************************************************
* CALL_ALV
************************************************************************
form call_alv.
data: wa_cat like line of alv_fldcat.
loop at it_fldcat into wa_it_fldcat.
wa_cat-fieldname = wa_it_fldcat-fieldname.
wa_cat-seltext_s = wa_it_fldcat-seltext.
wa_cat-outputlen = wa_it_fldcat-outputlen.
append wa_cat to alv_fldcat.
endloop.
* Call ABAP List Viewer (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = alv_fldcat
tables
t_outtab = <dyn_table>.
endform.
Regards,
Rich Heilman
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |