Sie sind auf Seite 1von 3

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

*& Report ZVIK_PROG01


*&
*&---------------------------------------------------------------------*
REPORT ZVIK_PROG01.
*01: Declare tables to be referred
tables: ekko,ekpo.
*02: Type declaration
Types:
begin of ty_output,
count type sy-index,
ebeln type ekko-ebeln,
bukrs type ekko-bukrs,
zterm type ekko-zterm,
lifnr type ekko-lifnr,
wkurs type ekko-wkurs,
waers type ekko-waers,
ekorg type ekko-ekorg,
ekgrp type ekko-ekgrp,
ebelp type ekpo-ebelp,
txz01 type ekpo-txz01,
menge type ekpo-menge,
netpr type ekpo-netpr,
end of ty_output.

"doc_no
"comp_code
"pay_term
"vendor
"ex_rate
"curr
"pur_org
"pur_grp
"line Item
"text
"PO qty
"netpr

*03: internal tables


*
Data:
it_output type standard table of ty_output,
it_ekko type standard table of ekko,
it_ekpo type standard table of ekpo.
*04 Work areas
*
data:
wa_output type ty_output,
wa_ekko type ekko,
wa_ekpo type ekpo,
wa_count type sy-index,
wa_var1 type ekko-ebeln.
*05 ALV References
*
DATA: go_alv TYPE REF TO cl_salv_table,
go_columns TYPE REF TO cl_salv_columns,
go_funcs TYPE REF TO cl_salv_functions,
go_ex TYPE REF TO cx_root.
************************************************************************
*06 SELECTION SCREEN DETAILS
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
PARAMETERS: p_var LIKE ekko-bukrs default 'A110'.
select-options:
p_var2 for wa_var1 default '1'.
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
PARAMETERS: r_hdr RADIOBUTTON GROUP RG DEFAULT 'X',
r_itm RADIOBUTTON GROUP RG.
SELECTION-SCREEN END OF BLOCK blk2.

************************************************************************
*07 SELECTION OF DATA
************************************************************************
* break-point.
perform selection.
* break-point.
perform output.

*&---------------------------------------------------------------------*
*&
Form SELECTION
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM SELECTION .
* Check the validity of the input
select * from ekko into table it_ekko where bukrs = p_var
and ebeln in p_var2.
select * from ekpo into table it_ekpo
for all entries in it_ekko
where bukrs = it_ekko-bukrs
and ebeln = it_ekko-ebeln.
IF sy-subrc <> 0.
* No data exists
MESSAGE 'No data exists for this PO.' TYPE 'I'.
EXIT.
ENDIF.
loop at it_ekpo into wa_ekpo.
clear: wa_output.
Read table it_ekko into wa_ekko with key
bukrs = wa_ekpo-bukrs
ebeln = wa_ekpo-ebeln.
move-corresponding wa_ekko to wa_output.
move-corresponding wa_ekpo to wa_output.
* Set Counter
wa_count = wa_count + 1.
wa_output-count = wa_count.
append wa_output to it_output.
endloop.

ENDFORM.
" SELECTION
*&---------------------------------------------------------------------*
*&
Form OUTPUT
*&---------------------------------------------------------------------*

*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM OUTPUT .
if R_hdr eq 'X'.
***
*Generating Output using ALV functions *
*Generate output using it_output table
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = go_alv
CHANGING
t_table = it_output ).
* "put your output internal table here
*
" set column optimized
go_columns = go_alv->get_columns( ).
go_columns->set_optimize( ).
" set functions
go_funcs = go_alv->get_functions( ).
go_funcs->set_all( ).
go_alv->display( ).
CATCH cx_salv_msg INTO go_ex.
MESSAGE go_ex TYPE 'E'.
ENDTRY.
else.
***
* Generating Output using Write statement
* Generate output using it_ekpo table
Write: 'Item data:'.
loop at it_ekpo into wa_ekpo.
write: /1 'Document:' , wa_ekpo-ebeln,
20 'line Item No.:', wa_ekpo-ebelp,
45 'Text:', wa_ekpo-txz01,
'Net Price:', wa_ekpo-netpr.
endloop.
endif.

ENDFORM.

" OUTPUT

Das könnte Ihnen auch gefallen