Вы находитесь на странице: 1из 42

630PM ALV OBJECTS:

PROGRAM1:
REPORT

Z630PMALV1

data : lv_vbeln type vbak-vbeln.


select-options : so_vbeln for lv_vbeln.
types : begin of ty_vbak,
vbeln type vbak-vbeln,
erdat type vbak-erdat,
erzet type vbak-erzet,
ernam type vbak-ernam,
end of ty_vbak.
data : lt_vbak type standard table of ty_vbak,
ls_vbak type ty_vbak.
data : vbak_cont type ref to cl_gui_custom_container,
vbak_grid type ref to cl_gui_alv_grid.
initialization.
so_vbeln-low = '4970'.
so_vbeln-high = '4974'.
append so_vbeln.
start-of-selection.
call screen 100.
module STATUS_0100 output.
set pf-status 'ABC'.
CREATE OBJECT vbak_cont
EXPORTING
container_name

CREATE OBJECT vbak_grid

= 'CCONT'.

EXPORTING
i_parent

= vbak_cont.

perform getvbak.
if lt_vbak[] is not initial.
perform displayvbak.
endif.
endmodule.

" STATUS_0100

OUTPUT

module USER_COMMAND_0100 input.


case sy-ucomm.
when 'BACK'.
leave program.
endcase.
endmodule.

" USER_COMMAND_0100

INPUT

form getvbak .
select vbeln erdat erzet ernam
from vbak
into table lt_vbak
where vbeln in so_vbeln.
endform.

" getvbak

form displayvbak .
CALL METHOD vbak_grid->set_table_for_first_display
CHANGING
it_outtab
endform.

= lt_vbak[].
" displayvbak

PROGRAM2:
REPORT

Z630PMALV1

data : lv_vbeln type vbak-vbeln.


select-options : so_vbeln for lv_vbeln.

types : begin of ty_vbak,


vbeln type vbak-vbeln,
erdat type vbak-erdat,
erzet type vbak-erzet,
ernam type vbak-ernam,
end of ty_vbak.
data : lt_vbak type standard table of ty_vbak,
ls_vbak type ty_vbak.
data : vbak_cont type ref to cl_gui_custom_container,
vbak_grid type ref to cl_gui_alv_grid.
initialization.
so_vbeln-low = '4970'.
so_vbeln-high = '4974'.
append so_vbeln.
start-of-selection.
call screen 100.
module STATUS_0100 output.
set pf-status 'ABC'.
CREATE OBJECT vbak_cont
EXPORTING
container_name

= 'CCONT'.

CREATE OBJECT vbak_grid


EXPORTING
i_parent

= vbak_cont.

perform getvbak.
if lt_vbak[] is not initial.
perform displayvbak.
endif.

endmodule.

" STATUS_0100

OUTPUT

module USER_COMMAND_0100 input.


case sy-ucomm.
when 'BACK'.
leave program.
endcase.
endmodule.

" USER_COMMAND_0100

INPUT

form getvbak .
select vbeln erdat erzet ernam
from vbak
into table lt_vbak
where vbeln in so_vbeln.
endform.

" getvbak

form displayvbak .
CALL METHOD vbak_grid->set_table_for_first_display
EXPORTING
I_STRUCTURE_NAME

= 'VBAK'

CHANGING
it_outtab
endform.

= lt_vbak[].
" displayvbak

PROGRAM3:
REPORT

Z630PMALV1

data : lv_vbeln type vbak-vbeln.


select-options : so_vbeln for lv_vbeln.
types : begin of ty_vbak,
vbeln type vbak-vbeln,
erdat type vbak-erdat,
erzet type vbak-erzet,

ernam type vbak-ernam,


end of ty_vbak.
data : lt_vbak type standard table of ty_vbak,
ls_vbak type ty_vbak.
data : vbak_cont type ref to cl_gui_custom_container,
vbak_grid type ref to cl_gui_alv_grid.
initialization.
so_vbeln-low = '4970'.
so_vbeln-high = '4974'.
append so_vbeln.
start-of-selection.
call screen 100.
module STATUS_0100 output.
set pf-status 'ABC'.
CREATE OBJECT vbak_cont
EXPORTING
container_name

= 'CCONT'.

CREATE OBJECT vbak_grid


EXPORTING
i_parent

= vbak_cont.

perform getvbak.
if lt_vbak[] is not initial.
perform displayvbak.
endif.
endmodule.

" STATUS_0100

module USER_COMMAND_0100 input.


case sy-ucomm.

OUTPUT

when 'BACK'.
leave program.
endcase.
endmodule.

" USER_COMMAND_0100

INPUT

form getvbak .
select vbeln erdat erzet ernam
from vbak
into table lt_vbak
where vbeln in so_vbeln.
endform.

" getvbak

form displayvbak .
CALL METHOD vbak_grid->set_table_for_first_display
EXPORTING
I_STRUCTURE_NAME

= 'ZMYVBAK'

CHANGING
it_outtab
endform.

= lt_vbak[].
" displayvbak

PROGRAM4:
REPORT

Z630PMALV3

data : lv_vbeln type vbak-vbeln.


select-options : so_vbeln for lv_vbeln.
types : begin of ty_vbak,
vbeln type vbak-vbeln,
erdat type vbak-erdat,
erzet type vbak-erzet,
ernam type vbak-ernam,
end of ty_vbak.
data : lt_vbak type standard table of ty_vbak,
ls_vbak type ty_vbak.

data : vbak_cont type ref to cl_gui_custom_container,


vbak_grid type ref to cl_gui_alv_grid.
data : lt_fcat type lvc_t_fcat.
initialization.
so_vbeln-low = '4970'.
so_vbeln-high = '4974'.
append so_vbeln.
start-of-selection.
call screen 100.
module STATUS_0100 output.
set pf-status 'ABC'.
CREATE OBJECT vbak_cont
EXPORTING
container_name

= 'CCONT'.

CREATE OBJECT vbak_grid


EXPORTING
i_parent

= vbak_cont.

perform getvbak.
if lt_vbak[] is not initial.
perform fldcat.
perform displayvbak.
endif.
endmodule.

" STATUS_0100

module USER_COMMAND_0100 input.


case sy-ucomm.
when 'BACK'.
leave program.

OUTPUT

endcase.
endmodule.

" USER_COMMAND_0100

INPUT

form getvbak .
select vbeln erdat erzet ernam
from vbak
into table lt_vbak
where vbeln in so_vbeln.
endform.

" getvbak

form displayvbak .
CALL METHOD vbak_grid->set_table_for_first_display
CHANGING
IT_FIELDCATALOG

= lt_fcat[]

it_outtab
endform.

= lt_vbak[].
" displayvbak

form fldcat .
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME

= 'ZMYVBAK'

CHANGING
ct_fieldcat
endform.

= lt_fcat[].
" fldcat

PROGRAM5:
REPORT

Z630PMALV3

data : lv_vbeln type vbak-vbeln.


select-options : so_vbeln for lv_vbeln.
types : begin of ty_vbak,
vbeln type vbak-vbeln,

erdat type vbak-erdat,


erzet type vbak-erzet,
ernam type vbak-ernam,
end of ty_vbak.
data : lt_vbak type standard table of ty_vbak,
ls_vbak type ty_vbak.
data : vbak_cont type ref to cl_gui_custom_container,
vbak_grid type ref to cl_gui_alv_grid.
data : lt_fcat type lvc_t_fcat,
*

ls_fcat type lvc_s_fcat,


ls_fcat like line of lt_fcat.

initialization.
so_vbeln-low = '4970'.
so_vbeln-high = '4974'.
append so_vbeln.
start-of-selection.
call screen 100.
module STATUS_0100 output.
set pf-status 'ABC'.
CREATE OBJECT vbak_cont
EXPORTING
container_name

= 'CCONT'.

CREATE OBJECT vbak_grid


EXPORTING
i_parent

= vbak_cont.

perform getvbak.
if lt_vbak[] is not initial.
perform fldcat.

perform displayvbak.
endif.
endmodule.

" STATUS_0100

OUTPUT

module USER_COMMAND_0100 input.


case sy-ucomm.
when 'BACK'.
leave program.
endcase.
endmodule.

" USER_COMMAND_0100

INPUT

form getvbak .
select vbeln erdat erzet ernam
from vbak
into table lt_vbak
where vbeln in so_vbeln.
endform.

" getvbak

form displayvbak .
CALL METHOD vbak_grid->set_table_for_first_display
CHANGING
IT_FIELDCATALOG
it_outtab
endform.

= lt_fcat[]
= lt_vbak[].
" displayvbak

form fldcat .
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME

= 'ZMYVBAK'

CHANGING
ct_fieldcat

= lt_fcat[].

if lt_fcat[] is not initial.


loop at lt_fcat into ls_fcat.
if ls_fcat-fieldname = 'ERDAT'.
ls_fcat-col_pos = 3.
ls_fcat-coltext = 'Creation Date'.
modify lt_fcat from ls_fcat transporting col_pos coltext.
elseif ls_fcat-fieldname = 'ERZET'.
ls_fcat-coltext = 'Creation Time'.
ls_fcat-col_pos = 2.
modify lt_fcat from ls_fcat transporting col_pos coltext.
endif.
endloop.
endif.

endform.

" fldcat

PROGRAM6:
REPORT

Z630PMALV3

data : lv_vbeln type vbak-vbeln.


select-options : so_vbeln for lv_vbeln.
types : begin of ty_vbak,
vbeln type vbak-vbeln,
erdat type vbak-erdat,
erzet type vbak-erzet,
ernam type vbak-ernam,
end of ty_vbak.
data : lt_vbak type standard table of ty_vbak,
ls_vbak type ty_vbak.
data : vbak_cont type ref to cl_gui_custom_container,
vbak_grid type ref to cl_gui_alv_grid.

data : lt_fcat type lvc_t_fcat.


field-symbols <fs> like line of lt_fcat.
initialization.
so_vbeln-low = '4970'.
so_vbeln-high = '4974'.
append so_vbeln.
start-of-selection.
call screen 100.
module STATUS_0100 output.
set pf-status 'ABC'.
CREATE OBJECT vbak_cont
EXPORTING
container_name

= 'CCONT'.

CREATE OBJECT vbak_grid


EXPORTING
i_parent

= vbak_cont.

perform getvbak.
if lt_vbak[] is not initial.
perform fldcat.
perform displayvbak.
endif.
endmodule.

" STATUS_0100

module USER_COMMAND_0100 input.


case sy-ucomm.
when 'BACK'.
leave program.
endcase.

OUTPUT

endmodule.

" USER_COMMAND_0100

INPUT

form getvbak .
select vbeln erdat erzet ernam
from vbak
into table lt_vbak
where vbeln in so_vbeln.
endform.

" getvbak

form displayvbak .
CALL METHOD vbak_grid->set_table_for_first_display
CHANGING
IT_FIELDCATALOG

= lt_fcat[]

it_outtab
endform.

= lt_vbak[].
" displayvbak

form fldcat .
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME

= 'ZMYVBAK'

CHANGING
ct_fieldcat

= lt_fcat[].

if lt_fcat[] is not initial.


loop at lt_fcat assigning <fs>.
if <fs>-fieldname = 'ERDAT'.
<fs>-col_pos = 3.
<fs>-coltext = 'Creation Date'.
elseif <fs>-fieldname = 'ERZET'.
<fS>-coltext = 'Creation Time'.
<fs>-col_pos = 2.
endif.
endloop.

endif.

endform.

" fldcat

PROGRAM7:
REPORT

Z630PMALV3

data : lv_vbeln type vbak-vbeln.


select-options : so_vbeln for lv_vbeln.
types : begin of ty_vbak,
vbeln type vbak-vbeln,
erdat type vbak-erdat,
erzet type vbak-erzet,
ernam type vbak-ernam,
end of ty_vbak.
data : lt_vbak type standard table of ty_vbak,
ls_vbak type ty_vbak.
data : vbak_cont type ref to cl_gui_custom_container,
vbak_grid type ref to cl_gui_alv_grid.
data : lt_fcat type lvc_t_fcat,
ls_fcat like line of lt_fcat.
data : ls_layo type lvc_s_layo.
initialization.
so_vbeln-low = '4970'.
so_vbeln-high = '4974'.
append so_vbeln.
start-of-selection.

call screen 100.


module STATUS_0100 output.
set pf-status 'ABC'.
CREATE OBJECT vbak_cont
EXPORTING
container_name

= 'CCONT'.

CREATE OBJECT vbak_grid


EXPORTING
i_parent

= vbak_cont.

perform getvbak.
if lt_vbak[] is not initial.
perform fldcat.
perform layout.
perform displayvbak.
endif.
endmodule.

" STATUS_0100

OUTPUT

module USER_COMMAND_0100 input.


case sy-ucomm.
when 'BACK'.
leave program.
endcase.
endmodule.

" USER_COMMAND_0100

form getvbak .
select vbeln erdat erzet ernam
from vbak
into table lt_vbak
where vbeln in so_vbeln.
endform.

" getvbak

INPUT

form displayvbak .
CALL METHOD vbak_grid->set_table_for_first_display
EXPORTING
IS_LAYOUT

= ls_layo

CHANGING
IT_FIELDCATALOG

= lt_fcat[]

it_outtab
endform.

= lt_vbak[].
" displayvbak

form fldcat .
clear ls_fcat.
ls_fcat-fieldname = 'VBELN'.
ls_fcat-col_pos = 1.
ls_fcat-coltext = 'Sales Doc'.
ls_fcat-outputlen = 10.
append ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'ERDAT'.
ls_fcat-col_pos = 2.
ls_fcat-coltext = 'DATE'.
ls_fcat-outputlen = 12.
append ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'ERZET'.
ls_fcat-col_pos = 3.
ls_fcat-coltext = 'TIME'.
ls_fcat-outputlen = 12.
append ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'ERNAM'.
ls_fcat-col_pos = 4.

ls_fcat-coltext = 'Created by'.


ls_fcat-outputlen = 12.
append ls_fcat to lt_fcat.

endform.

" fldcat

form layout .
clear ls_layo.
ls_layo-zebra = 'X'.
ls_layo-grid_title = 'SALES DOCUMENT HEADER DATA'.
endform.

" layout

PROGRAM8:
report

z630pmalv8

types : begin of ty_kna1,


kunnr type kna1-kunnr,
land1 type kna1-land1,
name1 type kna1-name1,
end of ty_kna1.
data : lt_kna1 type standard table of ty_kna1,
ls_kna1 type ty_kna1.
types : begin of ty_vbak,
vbeln type vbak-vbeln,
erdat type vbak-erdat,
ernam type vbak-ernam,
kunnr type vbak-kunnr,
end of ty_vbak.
data : lt_vbak type standard table of ty_vbak,
ls_vbak type ty_vbak.
data : kna1_cont type ref to cl_gui_custom_container,
kna1_grid type ref to cl_gui_alv_grid.

data : vbak_cont type ref to cl_gui_custom_container,


vbak_grid type ref to cl_gui_alv_grid.

data : lt_fcat type lvc_t_fcat,


ls_fcat type lvc_s_fcat.
data ls_layo type lvc_s_layo.
data lv_kunnr type kna1-kunnr.
class lcl_eventreceiver definition.
public section.
methods handle_hotspot_click for event hotspot_click
of cl_gui_alv_grid importing e_row_id.
endclass.
class lcl_eventreceiver implementation.
method handle_hotspot_click.
read table lt_kna1 into ls_kna1 index e_row_id-index.
if sy-subrc eq 0.
lv_kunnr = ls_kna1-kunnr.
if lv_kunnr is not initial.
perform getvbak.
if sy-subrc eq 0.
call screen 200.
else.
message 'No sales doc' type 'I'.
endif.
endif.
endif.
endmethod.
endclass.
data ob type ref to lcl_eventreceiver.

start-of-selection.
call screen 100.
module status_0100 output.
set pf-status 'ABC'.
if kna1_cont is initial.
create object kna1_cont
exporting
container_name

= 'CUST1'.

create object kna1_grid


exporting
i_parent

= kna1_cont.

perform getkna1.
if lt_kna1[] is not initial.
perform fldcatkna1.
perform layoutkna1.
perform registerhandlers.
perform displaykna1.
endif.
endif.
endmodule.

" STATUS_0100

form getkna1 .
select kunnr land1 name1
from kna1
into table lt_kna1
where land1 = 'DE'.
endform.

" getkna1

form fldcatkna1 .
clear ls_fcat.
ls_fcat-fieldname = 'KUNNR'.
ls_fcat-col_pos = 1.

OUTPUT

ls_fcat-coltext = 'Customer No'.


ls_fcat-outputlen = 12.
ls_fcat-hotspot = 'X'.
append ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'LAND1'.
ls_fcat-col_pos = 2.
ls_fcat-coltext = 'Country'.
ls_fcat-outputlen = 7.
append ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'NAME1'.
ls_fcat-col_pos = 3.
ls_fcat-coltext = 'Customer Name'.
ls_fcat-outputlen = 12.
append ls_fcat to lt_fcat.

endform.

" fldcatkna1

form layoutkna1 .
clear ls_layo.
ls_layo-zebra = 'X'.
ls_layo-grid_title = 'CUSTOMER MASTER DATA'.
endform.

" layoutkna1

form displaykna1 .
call method kna1_grid->set_table_for_first_display
exporting
is_layout
changing

= ls_layo

it_outtab

= lt_kna1[]

it_fieldcatalog

= lt_fcat[].

endform.

" displaykna1

module user_command_0100 input.


case sy-ucomm.
when 'BACK'.
leave program.
endcase.
endmodule.

" USER_COMMAND_0100

INPUT

form registerhandlers .
create object ob.
set handler ob->handle_hotspot_click for kna1_grid.
endform.

" registerhandlers

form getvbak .
select vbeln erdat ernam kunnr
from vbak
into table lt_vbak
where kunnr = lv_kunnr.
endform.

" getvbak

module status_0200 output.


set pf-status 'PQR'.
if vbak_cont is initial.
create object vbak_cont
exporting
container_name

= 'CUST2'.

create object vbak_grid


exporting
i_parent

= vbak_cont.

perform fldcatvbak.
perform layoutvbak.
perform displayvbak.
else.
call method vbak_grid->refresh_table_display.
endif.
endmodule.

" STATUS_0200

form fldcatvbak .
refresh lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'VBELN'.
ls_fcat-col_pos = 1.
ls_fcat-coltext = 'Sales Doc'.
ls_fcat-outputlen = 10.
append ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'ERDAT'.
ls_fcat-col_pos = 2.
ls_fcat-coltext = 'Creation Date'.
ls_fcat-outputlen = 12.
append ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'ERNAM'.
ls_fcat-col_pos = 3.
ls_fcat-coltext = 'Created By'.
ls_fcat-outputlen = 10.
append ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'KUNNR'.
ls_fcat-col_pos = 4.
ls_fcat-coltext = 'Customer no'.

OUTPUT

ls_fcat-outputlen = 10.
append ls_fcat to lt_fcat.

endform.

" fldcatvbak

form layoutvbak .
clear ls_layo.
ls_layo-grid_title = 'SALES DOCUMENT HEADER DATA'.
ls_layo-zebra = 'X'.
endform.

" layoutvbak

form displayvbak .
call method vbak_grid->set_table_for_first_display
exporting
is_layout

= ls_layo

changing
it_outtab

= lt_vbak[]

it_fieldcatalog

= lt_fcat[].

endform.

" displayvbak

module user_command_0200 input.


case sy-ucomm.
when 'BACK'.
leave to screen 100.
endcase.
endmodule.

" USER_COMMAND_0200

PROGRAM8(10-11-2011):
report

z630pmalv8

INPUT

types : begin of ty_kna1,


kunnr type kna1-kunnr,
land1 type kna1-land1,
name1 type kna1-name1,
end of ty_kna1.
data : lt_kna1 type standard table of ty_kna1,
ls_kna1 type ty_kna1.
types : begin of ty_vbak,
vbeln type vbak-vbeln,
erdat type vbak-erdat,
ernam type vbak-ernam,
kunnr type vbak-kunnr,
end of ty_vbak.
data : lt_vbak type standard table of ty_vbak,
ls_vbak type ty_vbak.
types : begin of ty_vbap,
vbeln type vbap-vbeln,
posnr type vbap-posnr,
matnr type vbap-matnr,
end of ty_vbap.
data : lt_vbap type standard table of ty_vbap,
ls_vbap type ty_vbap.
types : begin of ty_mara,
matnr type mara-matnr,
mtart type mara-mtart,
matkl type mara-matkl,
end of ty_mara.
data : lt_mara type standard table of ty_mara,
ls_mara type ty_mara.

data : kna1_cont type ref to cl_gui_custom_container,


kna1_grid type ref to cl_gui_alv_grid.
data : vbak_cont type ref to cl_gui_custom_container,
vbak_grid type ref to cl_gui_alv_grid.
data : vbap_cont type ref to cl_gui_custom_container,
vbap_grid type ref to cl_gui_alv_grid.
data : mara_cont type ref to cl_gui_custom_container,
mara_grid type ref to cl_gui_alv_grid.

data : lt_fcat type lvc_t_fcat,


ls_fcat type lvc_s_fcat.
data ls_layo type lvc_s_layo.
data lv_kunnr type kna1-kunnr.
data lv_vbeln type vbak-vbeln.
data lv_matnr type mara-matnr.
class lcl_eventreceiver definition.
public section.
methods handle_hotspot_click for event hotspot_click
of cl_gui_alv_grid importing e_row_id.
methods handle_double_click for event double_click
of cl_gui_alv_grid importing e_row.
methods handle_button_click for event button_click
of cl_gui_alv_grid importing es_row_no.
endclass.
class lcl_eventreceiver implementation.
method handle_hotspot_click.
read table lt_kna1 into ls_kna1 index e_row_id-index.
if sy-subrc eq 0.

lv_kunnr = ls_kna1-kunnr.
if lv_kunnr is not initial.
perform getvbak.
if sy-subrc eq 0.
call screen 200.
else.
message 'No sales doc' type 'I'.
endif.
endif.
endif.
endmethod.
method handle_double_click.
read table lt_vbak into ls_vbak index e_row-index.
if sy-subrc eq 0.
lv_vbeln = ls_vbak-vbeln.
if lv_vbeln is not initial.
perform getvbap.
if lt_vbap[] is not initial.
call screen 300.
else.
message 'No items' type 'I'.
endif.
endif.
endif.
endmethod.
method handle_button_click.
read table lt_vbap into ls_vbap
index es_row_no-row_id.
if sy-subrc eq 0.
lv_matnr = ls_vbap-matnr.
if lv_matnr is not initial.
perform getmaterial.
if lt_mara[] is not initial.
call screen 400.
else.

message 'No material data' type 'I'.


endif.
endif.
endif.
endmethod.
endclass.
data ob type ref to lcl_eventreceiver.
start-of-selection.
call screen 100.
module status_0100 output.
set pf-status 'ABC'.
if kna1_cont is initial.
create object kna1_cont
exporting
container_name

= 'CUST1'.

create object kna1_grid


exporting
i_parent

= kna1_cont.

perform getkna1.
if lt_kna1[] is not initial.
perform fldcatkna1.
perform layoutkna1.
perform registerhandlers.
perform displaykna1.
endif.
endif.
endmodule.

form getkna1 .
select kunnr land1 name1

" STATUS_0100

OUTPUT

from kna1
into table lt_kna1
where land1 = 'DE'.
endform.

" getkna1

form fldcatkna1 .
clear ls_fcat.
ls_fcat-fieldname = 'KUNNR'.
ls_fcat-col_pos = 1.
ls_fcat-coltext = 'Customer No'.
ls_fcat-outputlen = 12.
ls_fcat-hotspot = 'X'.
append ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'LAND1'.
ls_fcat-col_pos = 2.
ls_fcat-coltext = 'Country'.
ls_fcat-outputlen = 7.
append ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'NAME1'.
ls_fcat-col_pos = 3.
ls_fcat-coltext = 'Customer Name'.
ls_fcat-outputlen = 12.
append ls_fcat to lt_fcat.

endform.

form layoutkna1 .
clear ls_layo.
ls_layo-zebra = 'X'.

" fldcatkna1

ls_layo-grid_title = 'CUSTOMER MASTER DATA'.


endform.

" layoutkna1

form displaykna1 .
call method kna1_grid->set_table_for_first_display
exporting
is_layout

= ls_layo

changing
it_outtab

= lt_kna1[]

it_fieldcatalog

= lt_fcat[].

endform.

" displaykna1

module user_command_0100 input.


case sy-ucomm.
when 'BACK'.
if kna1_cont is not initial.
if vbak_cont is not initial.
if vbap_cont is not initial.
if mara_cont is not initial.
call method mara_grid->free.
call method mara_cont->free.
endif.
call method vbap_grid->free.
call method vbap_cont->free.
endif.
call method vbak_grid->free.
call method vbak_cont->free.
endif.
call method kna1_grid->free.
call method kna1_cont->free.
endif.
leave program.
endcase.
endmodule.

" USER_COMMAND_0100

INPUT

form registerhandlers .
create object ob.
set handler ob->handle_hotspot_click for kna1_grid.
endform.

" registerhandlers

form getvbak .
select vbeln erdat ernam kunnr
from vbak
into table lt_vbak
where kunnr = lv_kunnr.
endform.

" getvbak

module status_0200 output.


set pf-status 'PQR'.
if vbak_cont is initial.
create object vbak_cont
exporting
container_name

= 'CUST2'.

create object vbak_grid


exporting
i_parent

= vbak_cont.

perform fldcatvbak.
perform layoutvbak.
perform register_handlers.
perform displayvbak.
else.
call method vbak_grid->refresh_table_display.
endif.
endmodule.

form fldcatvbak .

" STATUS_0200

OUTPUT

refresh lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'VBELN'.
ls_fcat-col_pos = 1.
ls_fcat-coltext = 'Sales Doc'.
ls_fcat-outputlen = 10.
append ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'ERDAT'.
ls_fcat-col_pos = 2.
ls_fcat-coltext = 'Creation Date'.
ls_fcat-outputlen = 12.
append ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'ERNAM'.
ls_fcat-col_pos = 3.
ls_fcat-coltext = 'Created By'.
ls_fcat-outputlen = 10.
append ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'KUNNR'.
ls_fcat-col_pos = 4.
ls_fcat-coltext = 'Customer no'.
ls_fcat-outputlen = 10.
append ls_fcat to lt_fcat.

endform.

" fldcatvbak

form layoutvbak .
clear ls_layo.
ls_layo-grid_title = 'SALES DOCUMENT HEADER DATA'.
ls_layo-zebra = 'X'.
endform.

" layoutvbak

form displayvbak .
call method vbak_grid->set_table_for_first_display
exporting
is_layout

= ls_layo

changing
it_outtab

= lt_vbak[]

it_fieldcatalog

= lt_fcat[].

endform.

" displayvbak

module user_command_0200 input.


case sy-ucomm.
when 'BACK'.
leave to screen 100.
endcase.
endmodule.

" USER_COMMAND_0200

INPUT

form register_handlers .
create object ob.
set handler ob->handle_double_click for vbak_grid.
endform.

" register_handlers

form getvbap .
select vbeln posnr matnr
from vbap into table lt_vbap
where vbeln = lv_vbeln.
endform.

" getvbap

module status_0300 output.


set pf-status 'ABC1'.
if vbap_cont is initial.
create object vbap_cont
exporting
container_name

= 'CUST3'.

create object vbap_grid


exporting
i_parent

= vbap_cont.

perform fldcatvbap.
perform layoutvbap.
perform register.
perform displayvbap.
else.
call method vbap_grid->refresh_table_display.
endif.

endmodule.

" STATUS_0300

form fldcatvbap .
refresh lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'VBELN'.
ls_fcat-col_pos = 1.
ls_fcat-coltext = 'Sales Doc'.
ls_fcat-outputlen = 10.
append ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'POSNR'.
ls_fcat-col_pos = 2.

OUTPUT

ls_fcat-coltext = 'Item no'.


ls_fcat-outputlen = 10.
append ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-col_pos = 3.
ls_fcat-coltext = 'Material'.
ls_fcat-outputlen = 10.
ls_fcat-style = cl_gui_alv_grid=>mc_style_button.
append ls_fcat to lt_fcat.

endform.

" fldcatvbap

form layoutvbap .
clear ls_layo.
ls_layo-grid_title = 'Sales Document Item data'.
ls_layo-zebra = 'X'.
endform.

" layoutvbap

form displayvbap .
call method vbap_grid->set_table_for_first_display
exporting
is_layout

= ls_layo

changing
it_outtab

= lt_vbap[]

it_fieldcatalog

= lt_fcat[].

endform.

" displayvbap

module user_command_0300 input.

case sy-ucomm.
when 'BACK'.
leave to screen 200.
endcase.
endmodule.

" USER_COMMAND_0300

INPUT

form register .
create object ob.
set handler ob->handle_button_click for vbap_grid.
endform.

" register

form getmaterial .
select single matnr mtart matkl
from mara
into ls_mara where matnr = lv_matnr.
if sy-subrc eq 0.
refresh lt_mara.
append ls_mara to lt_mara.
endif.
endform.

" getmaterial

*&--------------------------------------------------------------------*
*&

Form

fldcatmara

*&--------------------------------------------------------------------*
*

text

*---------------------------------------------------------------------*
*

-->

p1

text

<--

p2

text

*---------------------------------------------------------------------*
form fldcatmara .
refresh lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'MATNR'.

ls_fcat-col_pos = 1.
ls_fcat-coltext = 'Material no'.
ls_fcat-outputlen = 10.
append ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'MTART'.
ls_fcat-col_pos = 2.
ls_fcat-coltext = 'Material Type'.
ls_fcat-outputlen = 10.
append ls_fcat to lt_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'MATKL'.
ls_fcat-col_pos = 3.
ls_fcat-coltext = 'Material Group'.
ls_fcat-outputlen = 10.
append ls_fcat to lt_fcat.

endform.

" fldcatmara

module status_0400 output.


set pf-status 'ABC2'.
if mara_cont is initial.
create object mara_cont
exporting
container_name

= 'CUST4'.

create object mara_grid


exporting
i_parent
perform fldcatmara.
perform layoutmara.

= mara_cont.

perform displaymara.
else.
call method mara_grid->refresh_table_display.
endif.
endmodule.

" STATUS_0400

OUTPUT

form layoutmara .
clear ls_layo.
ls_layo-grid_title = 'MATERIAL MASTER DATA'.
ls_layo-zebra

= 'X'.

endform.

" layoutmara

form displaymara .
call method mara_grid->set_table_for_first_display
exporting
is_layout

= ls_layo

changing
it_outtab

= lt_mara[]

it_fieldcatalog

= lt_fcat[].

endform.

" displaymara

module user_command_0400 input.


case sy-ucomm.
when 'BACK'.
leave to screen 300.
endcase.
endmodule.

" USER_COMMAND_0400

INPUT

PROGRAM9:
report

z630pmalv9

types : begin of ty_nodes.


include structure abdemonode.
types end of ty_nodes.

data : lt_nodes type standard table of ty_nodes,


ls_nodes type ty_nodes.
data : cust_cont type ref to cl_gui_custom_container,
o_split type ref to cl_gui_splitter_container,
o_cont1 type ref to cl_gui_container,
o_cont2 type ref to cl_gui_container,
o_tree type ref to cl_gui_simple_tree.
start-of-selection.
call screen 100.

module status_0100 output.


set pf-status 'ABC'.
if cust_cont is initial.
create object cust_cont
exporting
container_name

= 'CUST1'.

create object o_split


exporting
parent

= cust_cont

rows

= 1

columns

= 2.

call method o_split->set_column_width


exporting
id

= 1

width

= 10.

call method o_split->set_column_width


exporting
id

= 2

width

= 7.

call method o_split->get_container


exporting
row

= 1

column

= 1

receiving
container = o_cont1.

call method o_split->get_container


exporting
row

= 1

column

= 2

receiving
container = o_cont2.
perform tree.
endif.

endmodule.

" STATUS_0100

OUTPUT

module user_command_0100 input.


case sy-ucomm.
when 'BACK'.
leave program.
endcase.
endmodule.

" USER_COMMAND_0100

form tree .
create object o_tree
exporting
parent

= o_cont1

node_selection_mode

cl_gui_simple_tree=>node_sel_mode_single.

INPUT

perform constructnodes.
call method o_tree->add_nodes
exporting
table_structure_name

= 'ABDEMONODE'

node_table

= lt_nodes[].

endform.

" tree

form constructnodes .
clear ls_nodes.
ls_nodes-node_key = 'ROOT'.
ls_nodes-isfolder = 'X'.
ls_nodes-expander = 'X'.
ls_nodes-text = 'Transactions'.
append ls_nodes to lt_nodes.
clear ls_nodes.
ls_nodes-node_key = 'SO'.
ls_nodes-relatkey = 'ROOT'.
ls_nodes-isfolder = 'X'.
ls_nodes-expander = 'X'.
ls_nodes-text = 'Sales order'.
append ls_nodes to lt_nodes.
clear ls_nodes.
ls_nodes-node_key = 'CSO'.
ls_nodes-relatkey = 'SO'.
ls_nodes-n_image = '@15@'.
ls_nodes-text = 'Create Sales order'.
append ls_nodes to lt_nodes.
clear ls_nodes.
ls_nodes-node_key = 'CHSO'.
ls_nodes-relatkey = 'SO'.
ls_nodes-n_image = '@15@'.

ls_nodes-text = 'Change Sales order'.


append ls_nodes to lt_nodes.
clear ls_nodes.
ls_nodes-node_key = 'PO'.
ls_nodes-relatkey = 'ROOT'.
ls_nodes-isfolder = 'X'.
ls_nodes-expander = 'X'.
ls_nodes-text = 'Purchase order'.
append ls_nodes to lt_nodes.
clear ls_nodes.
ls_nodes-node_key = 'CPO'.
ls_nodes-relatkey = 'PO'.
ls_nodes-n_image = '@15@'.
ls_nodes-text = 'Create PO'.
append ls_nodes to lt_nodes.
clear ls_nodes.
ls_nodes-node_key = 'CHPO'.
ls_nodes-relatkey = 'PO'.
ls_nodes-n_image = '@15@'.
ls_nodes-text = 'Change PO'.
append ls_nodes to lt_nodes.

endform.

PROGRAM10:
PROGRAM11:
PROGRAM12:
PROGRAM13:
PROGRAM14:
PROGRAM15:
PROGRAM16:
PROGRAM17:
PROGRAM18:

" constructnodes

PROGRAM19:
PROGRAM20:

Вам также может понравиться