*&---------------------------------------------------------------------*
*& Report ZB12_BRANCHING_STAT_IF_7
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZB12_PARAMTERS_27.
parameters: num1 type i,
num2 type i.
*parameters: add type c as checkbox,
* sub type c as checkbox,
* mul type c as checkbox,
* div type c as checkbox.
*
* data : result type i.
*
* if add = 'X'. " X should be capital letter
*
* result = num1 + num2.
*
* elseif sub = 'X'.
*
* result = num1 - num2.
*
* elseif mul = 'X'.
*
* result = num1 * num2.
*
* elseif div = 'X'.
*
* result = num1 / num2.
* else.
* result = ' '.
*
* endif.
*write:/ result.
* if header = 'X' and item = 'X'.
parameters : add radiobutton group g1 ,
sub radiobutton group g1 default 'X',
mul radiobutton group g1,
div radiobutton group g1.
data : result type i.
if add = 'X'. " X should be capital letter
result = num1 + num2.
elseif sub = 'X'.
result = num1 - num2.
elseif mul = 'X'.
result = num1 * num2.
elseif div = 'X'.
result = num1 / num2.
else.
result = ' '.
endif.
write:/ result.
break-point.
*&---------------------------------------------------------------------*
*& Report ZB12_CLASICAL_REPORT_28
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZB12_CLASICAL_REPORT_28 no standard page heading line-size 500
line-count 20(3) message-id 00.
tables : ekko.
* data Declaration.
TYPES: BEGIN OF LS_final,
EBELN TYPE EBELN, " EKKO
BUKRS TYPE BUKRS,
BSART TYPE ESART,
AEDAT TYPE ERDAT,
LIFNR TYPE ELIFN,
EKORG TYPE EKORG,
EKGRP TYPE BKGRP,
EBELP TYPE EBELP, "EKPO
MATNR TYPE MATNR,
KTMNG TYPE KTMNG,
MENGE TYPE BSTMG,
MEINS TYPE BSTME,
BPRME TYPE BBPRM,
ETENR TYPE EETEN, " EKET
EINDT TYPE EINDT,
SLFDT TYPE SLFDT,
LPEIN TYPE LPEIN,
BANFN TYPE BANFN,
land1 type lfa1-land1,
name1 type lfa1-name1,
ort01 type lfa1-ort01,
maktx type makt-maktx,
END OF LS_final.
DATA : IT_final TYPE STANDARD TABLE OF LS_final,
WA_final LIKE LINE OF IT_final.
DATA : IT_DUMMY TYPE STANDARD TABLE OF LS_final,
WA_DUMMY LIKE LINE OF IT_DUMMY.
TYPES : BEGIN OF LS_LFA1,
LIFNR TYPE LFA1-LIFNR,
land1 type lfa1-land1,
name1 type lfa1-name1,
ort01 type lfa1-ort01,
END OF LS_LFA1.
DATA : IT_LFA1 TYPE STANDARD TABLE OF LS_LFA1,
WA_LFA1 LIKE LINE OF IT_LFA1.
TYPES : BEGIN OF LS_MAKT,
MATNR TYPE MAKT-MATNR,
maktx type makt-maktx,
END OF LS_MAKT.
DATA : IT_MAKT TYPE STANDARD TABLE OF LS_MAKT,
WA_MAKT LIKE LINE OF IT_MAKT.
* * selection screen
selection-screen : begin of block b1 with frame title text-001.
Parameters : p_ekorg type ekko-ekorg.
select-options : s_date for ekko-aedat.
selection-screen : end of block b1.
* fisrt eventin report is initialization event.
* we use to populate default values in selection selection.
initialization.
p_ekorg = '1000'.
data: date1 type sy-datum,
date2 type sy-datum.
date1 = sy-datum. "20080618.
date1+6(2) = '01'.
date2 = sy-datum.
s_date-sign = 'I'.
s_date-option = 'BT'.
s_date-low = date1.
s_date-high = date2.
append s_date to s_date.
at selection-screen.
if p_ekorg is initial and s_date-low is initial.
message e001 with 'selection screen should not be empty'.
endif.
at selection-screen on p_ekorg.
if p_ekorg > '0001' and p_ekorg < '3000'.
message e002.
endif.
start-of-selection.
SELECT A~EBELN
A~BUKRS
A~BSART
A~AEDAT
A~LIFNR
A~EKORG
A~EKGRP
B~EBELP
B~MATNR
B~KTMNG
B~MENGE
B~MEINS
B~BPRME
C~ETENR
C~EINDT
C~SLFDT
C~LPEIN
C~BANFN
FROM ( ( EKKO AS A INNER JOIN EKPO AS B
ON A~EBELN = B~EBELN ) INNER JOIN EKET AS C
ON B~EBELN = C~EBELN AND
B~EBELP = C~EBELP )
INTO TABLE IT_FINAL
WHERE A~EKORG = '3000'.
IF SY-SUBRC = 0.
SORT IT_FINAL BY EBELN EBELP ETENR.
ENDIF.
IT_DUMMY[] = IT_FINAL[].
IF IT_DUMMY[] IS NOT INITIAL.
SORT IT_DUMMY BY LIFNR.
DELETE ADJACENT DUPLICATES FROM IT_DUMMY comparing LIFNR.
SELECT LIFNR LAND1 NAME1 ORT01
FROM LFA1
INTO TABLE IT_LFA1 FOR ALL ENTRIES IN IT_DUMMY
WHERE LIFNR = IT_DUMMY-LIFNR.
IF SY-SUBRC = 0.
SORT IT_LFA1 BY LIFNR.
ENDIF.
REFRESH IT_DUMMY[].
IT_DUMMY[] = IT_FINAL[].
SORT IT_DUMMY BY MATNR.
DELETE adjacent DUPLICATES FROM IT_DUMMY COMPARING MATNR.
SELECT MATNR MAKTX
FROM MAKT
INTO TABLE IT_MAKT FOR ALL ENTRIES IN IT_DUMMY
WHERE MATNR = IT_DUMMY-MATNR AND
SPRAS = 'EN'.
IF SY-SUBRC = 0.
SORT IT_MAKT BY MATNR.
ENDIF.
ENDIF.
REFRESH IT_DUMMY.
end-of-selection.
CLEAR : WA_FINAL,
WA_LFA1,
WA_MAKT.
LOOP AT IT_FINAL INTO WA_FINAL.
READ TABLE IT_LFA1 INTO WA_LFA1 WITH KEY LIFNR = WA_FINAL-LIFNR
BINARY SEARCH.
IF SY-SUBRC = 0 .
WA_FINAL-LAND1 = WA_LFA1-LAND1.
WA_FINAL-NAME1 = WA_LFA1-NAME1.
WA_FINAL-ORT01 = WA_LFA1-ORT01.
ENDIF.
READ TABLE IT_MAKT INTO WA_MAKT WITH KEY MATNR = WA_FINAL-MATNR
BINARY SEARCH.
IF SY-SUBRC = 0.
WA_FINAL-MAKTX = WA_MAKT-MAKTX.
ENDIF.
MODIFY IT_FINAL FROM WA_FINAL.
WRITE:/ SY-VLINE, WA_FINAL-EBELN, SY-VLINE,
WA_FINAL-BUKRS, SY-VLINE,
WA_FINAL-BSART, SY-VLINE,
WA_FINAL-AEDAT, SY-VLINE,
WA_FINAL-LIFNR, SY-VLINE,
WA_FINAL-LAND1, SY-VLINE,
WA_FINAL-NAME1, SY-VLINE,
WA_FINAL-ORT01, SY-VLINE,
WA_FINAL-EKORG, SY-VLINE,
WA_FINAL-EKGRP, SY-VLINE,
WA_FINAL-EBELP, SY-VLINE,
WA_FINAL-MATNR, SY-VLINE,
WA_FINAL-MAKTX, SY-VLINE,
WA_FINAL-KTMNG, SY-VLINE,
WA_FINAL-MENGE, SY-VLINE,
WA_FINAL-MEINS, SY-VLINE,
WA_FINAL-BPRME, SY-VLINE,
WA_FINAL-ETENR, SY-VLINE,
WA_FINAL-EINDT, SY-VLINE,
WA_FINAL-SLFDT, SY-VLINE,
WA_FINAL-LPEIN, SY-VLINE,
WA_FINAL-BANFN, SY-VLINE,
WA_FINAL-LAND1, SY-VLINE,
WA_FINAL-NAME1, SY-VLINE,
WA_FINAL-ORT01, SY-VLINE.
CLEAR : WA_FINAL,
WA_LFA1,
WA_MAKT.
ULINE.
ENDLOOP.
top-of-page.
WRITE: /30'PURCHASE ORDER DETAILS REPORT' color 6.
WRITE: /5 'REPORT EXE BY:' color 5, SY-UNAME color 6.
WRITE: /5 'REPORT EXE ON:' color 5, SY-DATUM color 6.
ULINE.
WRITE:/ SY-VLINE, 2 'PO DOC', 14 SY-VLINE, 'POITM',21 SY-VLINE .
ULINE.
END-OF-PAGE.
ULINE.
WRITE:/ 'PAGENO:',SY-PAGNO.
*&---------------------------------------------------------------------*
*& Report ZB12_FIELD_SYMBOLS_29
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZB12_FIELD_SYMBOLS_29.
data : city(10) type c,
pin(10) type n.
field-symbols: <fs_var> type any.
city = 'bangalore'.
pin = '99999999'.
write:/ city,
pin.
assign city to <fs_var>.
<fs_var> = 'hyderbad'.
assign pin to <fs_var>.
<fs_var> = '560037'.
skip.
write:/ city,
pin.
*&---------------------------------------------------------------------*
*& Report ZB12_ITAB_READ_LOOP_14_FS.
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZB12_ITAB_MODIFY_15_USING_FS.
types : begin of ls_emp,
empno(4) type c,
empname(20) type c,
dept(10) type c,
sal type p,
end of ls_emp.
data : it_emp type standard table of ls_emp,
wa_emp like line of it_emp.
wa_emp-empno = '3000'.
wa_emp-empname = 'murali'.
wa_emp-dept = 'java'.
wa_emp-sal = '1200'.
append wa_emp to it_emp.
clear wa_emp.
wa_emp-empno = '4200'.
wa_emp-empname = 'vijay'.
wa_emp-dept = 'sap'.
wa_emp-sal = '1300'.
append wa_emp to it_emp.
clear wa_emp.
wa_emp-empno = '3200'.
wa_emp-empname = 'krisna'.
wa_emp-dept = 'sap'.
wa_emp-sal = '1400'.
append wa_emp to it_emp.
clear wa_emp.
wa_emp-empno = '3000'.
wa_emp-empname = 'murali'.
wa_emp-dept = 'sap'.
wa_emp-sal = '1500'.
append wa_emp to it_emp.
clear wa_emp.
wa_emp-empno = '4203'.
wa_emp-empname = 'vijaya'.
wa_emp-dept = 'java'.
wa_emp-sal = '1300'.
append wa_emp to it_emp.
clear wa_emp.
wa_emp-empno = '5203'.
wa_emp-empname = 'yesyeskar'.
wa_emp-dept = 'main'.
wa_emp-sal = '1500'.
append wa_emp to it_emp.
clear wa_emp.
wa_emp-empno = '5203'.
wa_emp-empname = 'preethi'.
wa_emp-dept = 'sap'.
wa_emp-sal = '1200'.
append wa_emp to it_emp.
clear wa_emp.
wa_emp-empno = '5250'.
wa_emp-empname = 'ranga'.
wa_emp-dept = 'java'.
wa_emp-sal = '1400'.
append wa_emp to it_emp.
clear wa_emp.
wa_emp-empno = '6700'.
wa_emp-empname = 'pandu'.
wa_emp-dept = 'main'.
wa_emp-sal = '1400'.
append wa_emp to it_emp.
clear wa_emp.
wa_emp-empno = '5200'.
wa_emp-empname = 'vijay'.
wa_emp-dept = 'main'.
wa_emp-sal = '1300'.
append wa_emp to it_emp.
clear wa_emp.
wa_emp-empno = '4543'.
wa_emp-empname = 'prasana'.
wa_emp-dept = 'sap'.
wa_emp-sal = '1500'.
append wa_emp to it_emp.
clear wa_emp.
*
data : lv_index type i.
field-symbols: <fs_emp> like line of it_emp.
*Modify with key based.
*loop at it_emp into wa_emp.
*
*
* wa_emp-sal = wa_emp-sal * 2.
*
* modify it_emp from wa_emp.
*
*
* write:/ wa_emp-empno, wa_emp-empname, wa_emp-dept, wa_emp-sal.
*
*
* clear wa_emp.
*
*endloop.
*Using field symbols
loop at it_emp assigning <fs_emp>.
<fs_emp>-sal = <fs_emp>-sal * 2.
* modify it_emp from wa_emp.
write:/ <fs_emp>-empno, <fs_emp>-empname, <fs_emp>-dept, <fs_emp>-sal.
* clear wa_emp.
endloop.
break-point.
*&---------------------------------------------------------------------*
*& Report ZB12_ITAB_EXP_HL_MODIFY_17_FS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZB12_ITAB_EXP_HL_MODIFY_17_FS.
TYPES: BEGIN OF LS_MAT,
MATNO TYPE MARA-MATNR,
EKORG TYPE EKKO-EKORG,
WERKS TYPE MARC-WERKS,
MTART TYPE MARA-MTART,
BPRICE TYPE P,
SPRICE TYPE P,
END OF LS_MAT.
DATA : IT_MAT TYPE LS_MAT OCCURS 0,
WA_MAT LIKE LINE OF IT_MAT.
WA_MAT-MATNO = 'M001'.
WA_MAT-EKORG = '1000'.
WA_MAT-WERKS = 'BANG'.
WA_MAT-MTART = 'FERT'.
WA_MAT-BPRICE = '1200'.
WA_MAT-SPRICE = '1200'.
APPEND WA_MAT TO IT_MAT.
CLEAR WA_MAT.
WA_MAT-MATNO = 'M201'.
WA_MAT-EKORG = '1100'.
WA_MAT-WERKS = 'BANG'.
WA_MAT-MTART = 'ROH'.
WA_MAT-BPRICE = '1201'.
WA_MAT-SPRICE = '1201'.
APPEND WA_MAT TO IT_MAT.
CLEAR WA_MAT.
WA_MAT-MATNO = 'M301'.
WA_MAT-EKORG = '1900'.
WA_MAT-WERKS = 'MANG'.
WA_MAT-MTART = 'FERT'.
WA_MAT-BPRICE = '1000'.
WA_MAT-SPRICE = '1000'.
APPEND WA_MAT TO IT_MAT.
CLEAR WA_MAT.
WA_MAT-MATNO = 'M002'.
WA_MAT-EKORG = '2000'.
WA_MAT-WERKS = 'HYD'.
WA_MAT-MTART = 'FERT'.
WA_MAT-BPRICE = '1205'.
WA_MAT-SPRICE = '1205'.
APPEND WA_MAT TO IT_MAT.
CLEAR WA_MAT.
WA_MAT-MATNO = 'M122'.
WA_MAT-EKORG = '2000'.
WA_MAT-WERKS = 'VIJ'.
WA_MAT-MTART = 'ROH'.
WA_MAT-BPRICE = '1000'.
WA_MAT-SPRICE = '1000'.
APPEND WA_MAT TO IT_MAT.
CLEAR WA_MAT.
WA_MAT-MATNO = 'M345'.
WA_MAT-EKORG = '2001'.
WA_MAT-WERKS = 'VIJ'.
WA_MAT-MTART = 'FERT'.
WA_MAT-BPRICE = '1100'.
WA_MAT-SPRICE = '1100'.
APPEND WA_MAT TO IT_MAT.
CLEAR WA_MAT.
WA_MAT-MATNO = 'M222'.
WA_MAT-EKORG = '2020'.
WA_MAT-WERKS = 'VZJ'.
WA_MAT-MTART = 'FERT'.
WA_MAT-BPRICE = '1001'.
WA_MAT-SPRICE = '1001'.
APPEND WA_MAT TO IT_MAT.
CLEAR WA_MAT.
WA_MAT-MATNO = 'M121'.
WA_MAT-EKORG = '2000'.
WA_MAT-WERKS = 'VIJ'.
WA_MAT-MTART = 'ROH'.
WA_MAT-BPRICE = '1000'.
WA_MAT-SPRICE = '1000'.
APPEND WA_MAT TO IT_MAT.
CLEAR WA_MAT.
WA_MAT-MATNO = 'M122'.
WA_MAT-EKORG = '2000'.
WA_MAT-WERKS = 'VIJ'.
WA_MAT-MTART = 'FOOD'.
WA_MAT-BPRICE = '1500'.
WA_MAT-SPRICE = '1500'.
APPEND WA_MAT TO IT_MAT.
CLEAR WA_MAT.
WA_MAT-MATNO = 'M123'.
WA_MAT-EKORG = '1900'.
WA_MAT-WERKS = 'MYS'.
WA_MAT-MTART = 'FOOD'.
WA_MAT-BPRICE = '1000'.
WA_MAT-SPRICE = '1000'.
APPEND WA_MAT TO IT_MAT.
CLEAR WA_MAT.
SORT IT_MAT BY MATNO.
* LOOP AT IT_MAT INTO WA_MAT.
*
* WRITE:/ WA_MAT-MATNO, WA_MAT-EKORG, WA_MAT-WERKS, WA_MAT-MTART,
* WA_MAT-BPRICE, WA_MAT-SPRICE.
*
** IF WA_MAT-MATNO = 'M001'.
**
** STOP. " stop with quit the program
**
**
** ENDIF.
*
*
*
* IF WA_MAT-MATNO = 'M122'.
*
** EXIT. " will stop the loop processing and continue statemetns after loop.
*
** CONTINUE. " will by pass stsatemtns after continue and before endloop and
** will continute with next iteration.
*
*
*
* ENDIF.
*
*
* IF WA_MAT-EKORG >= '1000' AND WA_MAT-EKORG < '2000'.
*
* CASE WA_MAT-WERKS .
*
* WHEN 'BANG'.
*
* IF WA_MAT-MTART = 'FERT'.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 2.
*
*
* ELSEIF WA_MAT-MTART = 'ROH'.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 2.
*
* ELSEIF WA_MAT-MTART = 'FOOD'.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 2.
*
* ELSE.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 2.
*
* ENDIF.
*
* WHEN 'MANG'.
*
* IF WA_MAT-MTART = 'FERT'.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 3.
*
*
* ELSEIF WA_MAT-MTART = 'ROH'.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 3.
*
* ELSEIF WA_MAT-MTART = 'FOOD'.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 3.
*
* ELSE.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 3.
*
* ENDIF.
*
*
*
* WHEN 'MYS'.
*
* IF WA_MAT-MTART = 'FERT'.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 4.
*
*
* ELSEIF WA_MAT-MTART = 'ROH'.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 4.
*
* ELSEIF WA_MAT-MTART = 'FOOD'.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 4.
*
* ELSE.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 4.
*
* ENDIF.
*
*
*
* WHEN OTHERS.
*
* ENDCASE.
*
* ELSEIF WA_MAT-EKORG >= '2000' AND WA_MAT-EKORG < '3000'.
*
* CASE WA_MAT-WERKS.
*
* WHEN 'HYD'.
*
* IF WA_MAT-MTART = 'FERT'.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 5.
*
*
* ELSEIF WA_MAT-MTART = 'ROH'.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 5.
*
* ELSEIF WA_MAT-MTART = 'FOOD'.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 5.
*
* ELSE.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 5.
*
* ENDIF.
*
*
*
*
* WHEN 'VIJ'.
*
*
* IF WA_MAT-MTART = 'FERT'.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 6.
*
*
* ELSEIF WA_MAT-MTART = 'ROH'.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 6.
*
* ELSEIF WA_MAT-MTART = 'FOOD'.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 6.
*
* ELSE.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 6.
*
* ENDIF.
*
* WHEN 'VZJ'.
*
*
* IF WA_MAT-MTART = 'FERT'.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 7.
*
*
* ELSEIF WA_MAT-MTART = 'ROH'.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 7.
*
* ELSEIF WA_MAT-MTART = 'FOOD'.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 7.
*
* ELSE.
*
* WA_MAT-SPRICE = WA_MAT-BPRICE * 7.
*
* ENDIF.
*
*
* WHEN OTHERS.
*
* ENDCASE.
*
*
*
*
*
* ELSE.
*
*
* ENDIF.
*
*
* MODIFY IT_MAT FROM WA_MAT.
*
* WRITE:/ WA_MAT-MATNO, WA_MAT-EKORG, WA_MAT-WERKS, WA_MAT-MTART,
* WA_MAT-BPRICE, WA_MAT-SPRICE.
*
** CLEAR WA_MAT.
* ENDLOOP.
*
*logic with field-symbols
field-symbols : <fs_mat> type ls_mat.
LOOP AT IT_MAT assigning <fs_mat>.
* WRITE:/ WA_MAT-MATNO, WA_MAT-EKORG, WA_MAT-WERKS, WA_MAT-MTART,
* WA_MAT-BPRICE, WA_MAT-SPRICE.
IF <fs_mat>-EKORG >= '1000' AND <fs_mat>-EKORG < '2000'.
CASE <fs_mat>-WERKS .
WHEN 'BANG'.
IF <fs_mat>-MTART = 'FERT'.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 2.
ELSEIF <fs_mat>-MTART = 'ROH'.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 2.
ELSEIF <fs_mat>-MTART = 'FOOD'.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 2.
ELSE.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 2.
ENDIF.
WHEN 'MANG'.
IF <fs_mat>-MTART = 'FERT'.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 3.
ELSEIF <fs_mat>-MTART = 'ROH'.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 3.
ELSEIF <fs_mat>-MTART = 'FOOD'.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 3.
ELSE.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 3.
ENDIF.
WHEN 'MYS'.
IF <fs_mat>-MTART = 'FERT'.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 4.
ELSEIF <fs_mat>-MTART = 'ROH'.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 4.
ELSEIF <fs_mat>-MTART = 'FOOD'.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 4.
ELSE.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 4.
ENDIF.
WHEN OTHERS.
ENDCASE.
ELSEIF <fs_mat>-EKORG >= '2000' AND <fs_mat>-EKORG < '3000'.
CASE <fs_mat>-WERKS.
WHEN 'HYD'.
IF <fs_mat>-MTART = 'FERT'.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 5.
ELSEIF <fs_mat>-MTART = 'ROH'.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 5.
ELSEIF <fs_mat>-MTART = 'FOOD'.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 5.
ELSE.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 5.
ENDIF.
WHEN 'VIJ'.
IF <fs_mat>-MTART = 'FERT'.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 6.
ELSEIF <fs_mat>-MTART = 'ROH'.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 6.
ELSEIF <fs_mat>-MTART = 'FOOD'.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 6.
ELSE.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 6.
ENDIF.
WHEN 'VZJ'.
IF <fs_mat>-MTART = 'FERT'.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 7.
ELSEIF <fs_mat>-MTART = 'ROH'.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 7.
ELSEIF <fs_mat>-MTART = 'FOOD'.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 7.
ELSE.
<fs_mat>-SPRICE = <fs_mat>-BPRICE * 7.
ENDIF.
WHEN OTHERS.
ENDCASE.
ELSE.
ENDIF.
* MODIFY IT_MAT FROM WA_MAT.
WRITE:/ <fs_mat>-MATNO, <fs_mat>-EKORG, <fs_mat>-WERKS, <fs_mat>-MTART,
<fs_mat>-BPRICE, <fs_mat>-SPRICE.
* CLEAR WA_MAT.
ENDLOOP.
*&---------------------------------------------------------------------*
*& Report ZB12_CLASICAL_REPORT_28
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZB12_CLASICAL_REPORT_28 no standard page heading line-size 500
line-count 20(3) message-id 00.
tables : ekko.
* data Declaration.
TYPES: BEGIN OF LS_final,
EBELN TYPE EBELN, " EKKO
BUKRS TYPE BUKRS,
BSART TYPE ESART,
AEDAT TYPE ERDAT,
LIFNR TYPE ELIFN,
EKORG TYPE EKORG,
EKGRP TYPE BKGRP,
EBELP TYPE EBELP, "EKPO
MATNR TYPE MATNR,
KTMNG TYPE KTMNG,
MENGE TYPE BSTMG,
MEINS TYPE BSTME,
BPRME TYPE BBPRM,
ETENR TYPE EETEN, " EKET
EINDT TYPE EINDT,
SLFDT TYPE SLFDT,
LPEIN TYPE LPEIN,
BANFN TYPE BANFN,
land1 type lfa1-land1,
name1 type lfa1-name1,
ort01 type lfa1-ort01,
maktx type makt-maktx,
END OF LS_final.
DATA : IT_final TYPE STANDARD TABLE OF LS_final,
WA_final LIKE LINE OF IT_final.
field-symbols :<fs_final> like line of it_final.
DATA : IT_DUMMY TYPE STANDARD TABLE OF LS_final,
WA_DUMMY LIKE LINE OF IT_DUMMY.
TYPES : BEGIN OF LS_LFA1,
LIFNR TYPE LFA1-LIFNR,
land1 type lfa1-land1,
name1 type lfa1-name1,
ort01 type lfa1-ort01,
END OF LS_LFA1.
DATA : IT_LFA1 TYPE STANDARD TABLE OF LS_LFA1,
WA_LFA1 LIKE LINE OF IT_LFA1.
TYPES : BEGIN OF LS_MAKT,
MATNR TYPE MAKT-MATNR,
maktx type makt-maktx,
END OF LS_MAKT.
DATA : IT_MAKT TYPE STANDARD TABLE OF LS_MAKT,
WA_MAKT LIKE LINE OF IT_MAKT.
* * selection screen
selection-screen : begin of block b1 with frame title text-001.
Parameters : p_ekorg type ekko-ekorg.
select-options : s_date for ekko-aedat.
selection-screen : end of block b1.
* fisrt eventin report is initialization event.
* we use to populate default values in selection selection.
initialization.
p_ekorg = '1000'.
data: date1 type sy-datum,
date2 type sy-datum.
date1 = sy-datum. "20080618.
date1+6(2) = '01'.
date2 = sy-datum.
s_date-sign = 'I'.
s_date-option = 'BT'.
s_date-low = date1.
s_date-high = date2.
append s_date to s_date.
at selection-screen.
if p_ekorg is initial and s_date-low is initial.
message e001 with 'selection screen should not be empty'.
endif.
at selection-screen on p_ekorg.
if p_ekorg > '0001' and p_ekorg < '3000'.
message e002.
endif.
start-of-selection.
SELECT A~EBELN
A~BUKRS
A~BSART
A~AEDAT
A~LIFNR
A~EKORG
A~EKGRP
B~EBELP
B~MATNR
B~KTMNG
B~MENGE
B~MEINS
B~BPRME
C~ETENR
C~EINDT
C~SLFDT
C~LPEIN
C~BANFN
FROM ( ( EKKO AS A INNER JOIN EKPO AS B
ON A~EBELN = B~EBELN ) INNER JOIN EKET AS C
ON B~EBELN = C~EBELN AND
B~EBELP = C~EBELP )
INTO TABLE IT_FINAL
WHERE A~EKORG = '3000'.
IF SY-SUBRC = 0.
SORT IT_FINAL BY EBELN EBELP ETENR.
ENDIF.
IT_DUMMY[] = IT_FINAL[].
IF IT_DUMMY[] IS NOT INITIAL.
SORT IT_DUMMY BY LIFNR.
DELETE ADJACENT DUPLICATES FROM IT_DUMMY comparing LIFNR.
SELECT LIFNR LAND1 NAME1 ORT01
FROM LFA1
INTO TABLE IT_LFA1 FOR ALL ENTRIES IN IT_DUMMY
WHERE LIFNR = IT_DUMMY-LIFNR.
IF SY-SUBRC = 0.
SORT IT_LFA1 BY LIFNR.
ENDIF.
REFRESH IT_DUMMY[].
IT_DUMMY[] = IT_FINAL[].
SORT IT_DUMMY BY MATNR.
DELETE adjacent DUPLICATES FROM IT_DUMMY COMPARING MATNR.
SELECT MATNR MAKTX
FROM MAKT
INTO TABLE IT_MAKT FOR ALL ENTRIES IN IT_DUMMY
WHERE MATNR = IT_DUMMY-MATNR AND
SPRAS = 'EN'.
IF SY-SUBRC = 0.
SORT IT_MAKT BY MATNR.
ENDIF.
ENDIF.
REFRESH IT_DUMMY.
end-of-selection.
CLEAR : WA_FINAL,
WA_LFA1,
WA_MAKT.
* LOOP AT IT_FINAL INTO WA_FINAL.
*
*
* READ TABLE IT_LFA1 INTO WA_LFA1 WITH KEY LIFNR = WA_FINAL-LIFNR
* BINARY SEARCH.
* IF SY-SUBRC = 0 .
*
* WA_FINAL-LAND1 = WA_LFA1-LAND1.
* WA_FINAL-NAME1 = WA_LFA1-NAME1.
* WA_FINAL-ORT01 = WA_LFA1-ORT01.
*
* ENDIF.
*
* READ TABLE IT_MAKT INTO WA_MAKT WITH KEY MATNR = WA_FINAL-MATNR
* BINARY SEARCH.
*
* IF SY-SUBRC = 0.
*
* WA_FINAL-MAKTX = WA_MAKT-MAKTX.
*
* ENDIF.
*
* MODIFY IT_FINAL FROM WA_FINAL.
*
*
*
*
* WRITE:/ SY-VLINE, WA_FINAL-EBELN, SY-VLINE,
* WA_FINAL-BUKRS, SY-VLINE,
* WA_FINAL-BSART, SY-VLINE,
* WA_FINAL-AEDAT, SY-VLINE,
* WA_FINAL-LIFNR, SY-VLINE,
* WA_FINAL-LAND1, SY-VLINE,
* WA_FINAL-NAME1, SY-VLINE,
* WA_FINAL-ORT01, SY-VLINE,
* WA_FINAL-EKORG, SY-VLINE,
* WA_FINAL-EKGRP, SY-VLINE,
*
* WA_FINAL-EBELP, SY-VLINE,
* WA_FINAL-MATNR, SY-VLINE,
* WA_FINAL-MAKTX, SY-VLINE,
* WA_FINAL-KTMNG, SY-VLINE,
* WA_FINAL-MENGE, SY-VLINE,
* WA_FINAL-MEINS, SY-VLINE,
* WA_FINAL-BPRME, SY-VLINE,
*
*
* WA_FINAL-ETENR, SY-VLINE,
* WA_FINAL-EINDT, SY-VLINE,
* WA_FINAL-SLFDT, SY-VLINE,
* WA_FINAL-LPEIN, SY-VLINE,
* WA_FINAL-BANFN, SY-VLINE,
* WA_FINAL-LAND1, SY-VLINE,
* WA_FINAL-NAME1, SY-VLINE,
* WA_FINAL-ORT01, SY-VLINE.
*
*
* CLEAR : WA_FINAL,
* WA_LFA1,
* WA_MAKT.
* ULINE.
*
* ENDLOOP.
*using field symbols
LOOP AT IT_FINAL assigning <fs_final>.
READ TABLE IT_LFA1 INTO WA_LFA1 WITH KEY LIFNR = <fs_final>-LIFNR
BINARY SEARCH.
IF SY-SUBRC = 0 .
<fs_final>-LAND1 = WA_LFA1-LAND1.
<fs_final>-NAME1 = WA_LFA1-NAME1.
<fs_final>-ORT01 = WA_LFA1-ORT01.
ENDIF.
READ TABLE IT_MAKT INTO WA_MAKT WITH KEY MATNR = <fs_final>-MATNR
BINARY SEARCH.
IF SY-SUBRC = 0.
<fs_final>-MAKTX = WA_MAKT-MAKTX.
ENDIF.
* MODIFY IT_FINAL FROM WA_FINAL.
WRITE:/ SY-VLINE, <fs_final>-EBELN, SY-VLINE,
<fs_final>-BUKRS, SY-VLINE,
<fs_final>-BSART, SY-VLINE,
<fs_final>-AEDAT, SY-VLINE,
<fs_final>-LIFNR, SY-VLINE,
<fs_final>-LAND1, SY-VLINE,
<fs_final>-NAME1, SY-VLINE,
<fs_final>-ORT01, SY-VLINE,
<fs_final>-EKORG, SY-VLINE,
<fs_final>-EKGRP, SY-VLINE,
<fs_final>-EBELP, SY-VLINE,
<fs_final>-MATNR, SY-VLINE,
<fs_final>-MAKTX, SY-VLINE,
<fs_final>-KTMNG, SY-VLINE,
<fs_final>-MENGE, SY-VLINE,
<fs_final>-MEINS, SY-VLINE,
<fs_final>-BPRME, SY-VLINE,
<fs_final>-ETENR, SY-VLINE,
<fs_final>-EINDT, SY-VLINE,
<fs_final>-SLFDT, SY-VLINE,
<fs_final>-LPEIN, SY-VLINE,
<fs_final>-BANFN, SY-VLINE,
<fs_final>-LAND1, SY-VLINE,
<fs_final>-NAME1, SY-VLINE,
<fs_final>-ORT01, SY-VLINE.
CLEAR : WA_FINAL,
WA_LFA1,
WA_MAKT.
ULINE.
ENDLOOP.
top-of-page.
WRITE: /30'PURCHASE ORDER DETAILS REPORT' color 6.
WRITE: /5 'REPORT EXE BY:' color 5, SY-UNAME color 6.
WRITE: /5 'REPORT EXE ON:' color 5, SY-DATUM color 6.
ULINE.
WRITE:/ SY-VLINE, 2 'PO DOC', 14 SY-VLINE, 'POITM',21 SY-VLINE .
ULINE.
END-OF-PAGE.
ULINE.
WRITE:/ 'PAGENO:',SY-PAGNO.
INCLUDE PROGRAMMS
*&---------------------------------------------------------------------*
*& Report ZB12_ITAB_PO_DETAILS_25
*&
REPORT ZB12_ITAB_PO_DETAILS_25 LINE-SIZE 500.
* DATA DECLARATION.
INCLUDE ZTOP_INCL.
PERFORM GET_PO_DATA.
PERFORM GET_VENDOR_DATA.
PERFORM GET_MATERIAL_DATA.
perform process_it_final_data.
*&---------------------------------------------------------------------*
*& Form GET_PO_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_PO_DATA .
SELECT A~EBELN
A~BUKRS
A~BSART
A~AEDAT
A~LIFNR
A~EKORG
A~EKGRP
B~EBELP
B~MATNR
B~KTMNG
B~MENGE
B~MEINS
B~BPRME
C~ETENR
C~EINDT
C~SLFDT
C~LPEIN
C~BANFN
FROM ( ( EKKO AS A INNER JOIN EKPO AS B
ON A~EBELN = B~EBELN ) INNER JOIN EKET AS C
ON B~EBELN = C~EBELN AND
B~EBELP = C~EBELP )
INTO TABLE IT_FINAL
WHERE A~EKORG = '3000'.
IF SY-SUBRC = 0.
SORT IT_FINAL BY EBELN EBELP ETENR.
ENDIF.
ENDFORM. " GET_PO_DATA
*&---------------------------------------------------------------------*
*& Form GET_VENDOR_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_VENDOR_DATA .
IT_DUMMY[] = IT_FINAL[].
IF IT_DUMMY[] IS NOT INITIAL.
SORT IT_DUMMY BY LIFNR.
DELETE ADJACENT DUPLICATES FROM IT_DUMMY comparing LIFNR.
SELECT LIFNR LAND1 NAME1 ORT01
FROM LFA1
INTO TABLE IT_LFA1 FOR ALL ENTRIES IN IT_DUMMY
WHERE LIFNR = IT_DUMMY-LIFNR.
IF SY-SUBRC = 0.
SORT IT_LFA1 BY LIFNR.
ENDIF.
ENDIF.
REFRESH IT_DUMMY[].
ENDFORM. " GET_VENDOR_DATA
*&---------------------------------------------------------------------*
*& Form GET_MATERIAL_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_MATERIAL_DATA .
IT_DUMMY[] = IT_FINAL[].
if not it_dummy[] is initial.
SORT IT_DUMMY BY MATNR.
DELETE adjacent DUPLICATES FROM IT_DUMMY COMPARING MATNR.
SELECT MATNR MAKTX
FROM MAKT
INTO TABLE IT_MAKT FOR ALL ENTRIES IN IT_DUMMY
WHERE MATNR = IT_DUMMY-MATNR AND
SPRAS = 'EN'.
IF SY-SUBRC = 0.
SORT IT_MAKT BY MATNR.
ENDIF.
endif.
REFRESH IT_DUMMY.
ENDFORM. " GET_MATERIAL_DATA
*&---------------------------------------------------------------------*
*& Form process_it_final_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM process_it_final_data .
CLEAR : WA_FINAL,
WA_LFA1,
WA_MAKT.
LOOP AT IT_FINAL INTO WA_FINAL.
READ TABLE IT_LFA1 INTO WA_LFA1 WITH KEY LIFNR = WA_FINAL-LIFNR
BINARY SEARCH.
IF SY-SUBRC = 0 .
WA_FINAL-LAND1 = WA_LFA1-LAND1.
WA_FINAL-NAME1 = WA_LFA1-NAME1.
WA_FINAL-ORT01 = WA_LFA1-ORT01.
ENDIF.
READ TABLE IT_MAKT INTO WA_MAKT WITH KEY MATNR = WA_FINAL-MATNR
BINARY SEARCH.
IF SY-SUBRC = 0.
WA_FINAL-MAKTX = WA_MAKT-MAKTX.
ENDIF.
MODIFY IT_FINAL FROM WA_FINAL.
WRITE:/ WA_FINAL-EBELN,
WA_FINAL-BUKRS,
WA_FINAL-BSART,
WA_FINAL-AEDAT,
WA_FINAL-LIFNR,
WA_FINAL-LAND1,
WA_FINAL-NAME1,
WA_FINAL-ORT01,
WA_FINAL-EKORG,
WA_FINAL-EKGRP,
WA_FINAL-EBELP,
WA_FINAL-MATNR,
WA_FINAL-MAKTX,
WA_FINAL-KTMNG,
WA_FINAL-MENGE,
WA_FINAL-MEINS,
WA_FINAL-BPRME,
WA_FINAL-ETENR,
WA_FINAL-EINDT,
WA_FINAL-SLFDT,
WA_FINAL-LPEIN,
WA_FINAL-BANFN,
WA_FINAL-LAND1,
WA_FINAL-NAME1,
WA_FINAL-ORT01.
ENDLOOP.
CLEAR : WA_FINAL,
WA_LFA1,
WA_MAKT.
ENDFORM. " process_it_final_data
*&---------------------------------------------------------------------*
*& Report ZB12_SUBROUTINES_30
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZB12_SUBROUTINES_30.
DATA : A TYPE I,
B TYPE I,
C TYPE I.
A = '10'.
B = '10'.
C = '10'.
WRITE:/' VALUES BEFORE SUB ROU CALL', A, B, C.
** 1 CALL BY VALUE.
*
*PERFORM GET_BY_VALUE USING A B C.
*
**
*WRITE:/ 'VALUES AFTER SUB ROU CALL', A, B, C.
*
*
*2. CALL BY REFERENCE
*PERFORM GET_CALL_BY_REFERENCE USING A B C.
*
*
*WRITE:/ 'VALUES AFTER SUB ROU CALL', A, B, C.
*3. CALL BY VALUE AND RETURN
*PERFORM GET_CALL_BY_VAL_RETURN CHANGING A B C.
*$.
C = '0'.
PERFORM GET_VALUE USING A B
CHANGING C.
WRITE:/ 'VALUES AFTER SUB ROU CALL', A, B, C.
**&---------------------------------------------------------------------*
**& Form GET_BY_VALUE
**&---------------------------------------------------------------------*
** text
**----------------------------------------------------------------------*
** -->P_A text
** -->P_B text
** -->P_C text
**----------------------------------------------------------------------*
*FORM GET_BY_VALUE USING VALUE(P_A)
* VALUE(P_B)
* VALUE(P_C).
*
*
*
* P_A = P_A + 2.
*
* P_B = P_B + 2.
*
* P_C = P_A + P_B + P_C.
*
* WRITE:/ 'VALUES IN ROUTINE', P_A, P_B, P_C.
*
*
*ENDFORM. " GET_BY_VALUE
*&---------------------------------------------------------------------*
*& Form GET_CALL_BY_REFERENCE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_A text
* -->P_B text
* -->P_C text
*----------------------------------------------------------------------*
*FORM GET_CALL_BY_REFERENCE USING P_A
* P_B
* P_C.
*
* P_A = P_A + 2.
*
* P_B = P_B + 2.
*
* P_C = P_A + P_B + P_C.
*
* WRITE:/ 'VALUES DURING ROUTINE', P_A, P_B, P_C.
*
*ENDFORM. " GET_CALL_BY_REFERENCE
*&---------------------------------------------------------------------*
*& Form GET_CALL_BY_VAL_RETURN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_A text
* <--P_B text
* <--P_C text
*----------------------------------------------------------------------*
*FORM GET_CALL_BY_VAL_RETURN CHANGING VALUE(P_A)
* VALUE(P_B)
* VALUE(P_C).
*
* P_A = P_A + 2.
*
* P_B = P_B + 2.
*
* P_C = P_A + P_B + P_C.
*
* WRITE:/ 'VALUES DURING ROUTINE', P_A, P_B, P_C.
*
*
*
*
*
*ENDFORM. " GET_CALL_BY_VAL_RETURN
*&---------------------------------------------------------------------*
*& Form GET_VALUE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_A text
* -->P_B text
* <--P_C text
*----------------------------------------------------------------------*
FORM GET_VALUE USING P_A
P_B
CHANGING P_C.
P_C = P_A * P_B.
WRITE:/ 'VALUES DURING ROUTINE', P_A, P_B, P_C.
ENDFORM. " GET_VALUE
*&---------------------------------------------------------------------*
*& Report ZB12_SUBROUTINES_31
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZB12_SUBROUTINES_31.
TYPES: BEGIN OF LS_VBAK,
VBELN TYPE VBELN_VA,
VBTYP TYPE VBTYP,
NETWR TYPE NETWR_AK,
WAERK TYPE WAERK,
VKORG TYPE VKORG,
VTWEG TYPE VTWEG,
SPART TYPE SPART,
END OF LS_VBAK.
TYPES : IT_VBAK TYPE STANDARD TABLE OF LS_VBAK.
DATA : IT_FINAL TYPE IT_VBAK,
WA_VBAK LIKE LINE OF IT_FINAL.
PARAMETERS : P_VKORG TYPE VBAK-VKORG.
PERFORM GET_SALES_DATA USING P_VKORG
CHANGING IT_FINAL.
P_VKORG = '3000'.
PERFORM GET_SALES_DATA USING P_VKORG
CHANGING IT_FINAL.
PERFORM WRITE_DATA TABLES IT_FINAL.
*&---------------------------------------------------------------------*
*& Form GET_SALES_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_VKORG text
* <--P_IT_FINAL text
*----------------------------------------------------------------------*
FORM GET_SALES_DATA USING P_P_VKORG LIKE P_VKORG
CHANGING P_IT_FINAL TYPE IT_VBAK.
SELECT VBELN
VBTYP
NETWR
WAERK
VKORG
VTWEG
SPART
FROM VBAK
INTO TABLE P_IT_FINAL
WHERE VKORG = P_P_VKORG.
ENDFORM. " GET_SALES_DATA
*&---------------------------------------------------------------------*
*& Form WRITE_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IT_FINAL text
*----------------------------------------------------------------------*
FORM WRITE_DATA TABLES P_IT_FINAL STRUCTURE WA_vbak.
FIELD-SYMBOLS : <FS_VBAK> LIKE LINE OF P_IT_FINAL.
LOOP AT P_IT_FINAL ASSIGNING <FS_VBAK>.
WRITE:/ <FS_VBAK>-VBELN,
<FS_VBAK>-VBTYP,
<FS_VBAK>-NETWR,
<FS_VBAK>-WAERK,
<FS_VBAK>-VKORG,
<FS_VBAK>-VTWEG,
<FS_VBAK>-SPART.
ENDLOOP.
ENDFORM.
- FUNCTION MODULES
*&---------------------------------------------------------------------*
*& Report ZB12_FM_CALL_32
REPORT ZB12_FM_CALL_32.
parameters: P_DATE TYPE SY-DATUM.
DATA : LV_BUPER LIKE T009B-POPER,
LV_GJAHR LIKE T009B-BDATJ,
LV_FISCPER TYPE /BI0/OIFISCPER.
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
I_DATE = P_DATE
* I_MONMIT = 00
I_PERIV = 'K4'
IMPORTING
E_BUPER = LV_BUPER
E_GJAHR = LV_GJAHR
* EXCEPTIONS
* INPUT_FALSE = 1
* T009_NOTFOUND = 2
* T009B_NOTFOUND = 3
* OTHERS = 4
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CONCATENATE LV_BUPER LV_GJAHR INTO LV_FISCPER.
WRITE:/ P_DATE,
/ LV_BUPER,
/ LV_BUPER,
/ LV_FISCPER.
FUNCTION Z_CUSTOMER_DATA.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(CUSTOMER) TYPE KUNNR
*" EXPORTING
*" REFERENCE(KUNNR) TYPE KUNNR
*" REFERENCE(LAND1) TYPE LAND1_GP
*" REFERENCE(NAME1) TYPE NAME1_GP
*" REFERENCE(NAME2) TYPE NAME2_GP
*" REFERENCE(ORT01) TYPE ORT01_GP
*" REFERENCE(PSTLZ) TYPE PSTLZ
*"----------------------------------------------------------------------
data : begin of ls_kna1,
KUNNR TYPE KUNNR,
LAND1 TYPE LAND1_GP,
NAME1 TYPE NAME1_GP,
NAME2 TYPE NAME2_GP,
ORT01 TYPE ORT01_GP,
PSTLZ TYPE PSTLZ,
end of ls_kna1.
select single kunnr land1 name1 name2
ort01 pstlz
from kna1 into ls_kna1
where kunnr = customer.
if sy-subrc = 0.
KUNNR = ls_kna1-KUNNR.
LAND1 = ls_kna1-LAND1.
NAME1 = ls_kna1-NAME1.
NAME2 = ls_kna1-NAME2.
ORT01 = ls_kna1-ORT01.
PSTLZ = ls_kna1-PSTLZ.
endif.
ENDFUNCTION.
FUNCTION Z_GET_PREVIOUS_DATE.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" CHANGING
*" REFERENCE(LS_DATE) TYPE SY-DATUM
*"----------------------------------------------------------------------
ls_date = ls_date - 1.
ENDFUNCTION.
FUNCTION Z_GET_START_ANDEND_DATE_OF_CUR.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(SYSTEM_DATE) TYPE SY-DATUM DEFAULT SY-DATUM
*" EXPORTING
*" REFERENCE(FIRST_DATE) TYPE SY-DATUM
*" REFERENCE(CURR_DATE) TYPE SY-DATUM
*"----------------------------------------------------------------------
FIRST_DATE = SYSTEM_DATE. "yyyymmdd " 20080624
FIRST_DATE+6(2) = '01'. " 20080601.
CURR_DATE = SYSTEM_DATE.
ENDFUNCTION.
FUNCTION DATE_TO_PERIOD_CONVERT.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(I_DATE) LIKE SY-DATUM
*" VALUE(I_MONMIT) LIKE GJVAR-MONMIT DEFAULT 00
*" VALUE(I_PERIV) LIKE T009B-PERIV
*" EXPORTING
*" VALUE(E_BUPER) LIKE T009B-POPER
*" VALUE(E_GJAHR) LIKE T009B-BDATJ
*" EXCEPTIONS
*" INPUT_FALSE
*" T009_NOTFOUND
*" T009B_NOTFOUND
*"----------------------------------------------------------------------
DATA: L_GJAHR TYPE P.
STATICS: BEGIN OF S_DTP,
GJAHR LIKE T009B-BDATJ,
PERIV LIKE T009-PERIV,
MONMIT LIKE GJVAR-MONMIT,
DATE LIKE SY-DATUM,
BUPER LIKE T009B-POPER.
STATICS: END OF S_DTP.
STATICS: ST_TKJ LIKE T009B OCCURS 52 WITH HEADER LINE.
STATICS: S_T009 LIKE T009.
DATA: BEGIN OF LD_DAT,
JAH LIKE T009B-BDATJ,
MON LIKE T009B-BUMON,
TAG LIKE T009B-BUTAG,
END OF LD_DAT.
***********************************************************************
* Haben sich die Eingabeparameter geaendert ?
IF I_DATE EQ S_DTP-DATE AND
I_PERIV EQ S_DTP-PERIV AND
I_MONMIT EQ S_DTP-MONMIT AND NOT
S_DTP-BUPER IS INITIAL.
MOVE: S_DTP-BUPER TO E_BUPER,
S_DTP-GJAHR TO E_GJAHR.
EXIT.
ENDIF.
CLEAR: S_DTP-BUPER, S_DTP-GJAHR.
* Uebergabe von Jahr, Monat, Tag.
MOVE: I_DATE TO LD_DAT.
* Periodenermittlungs-Version aus T009 lesen.
PERFORM INIT_TABKJ TABLES ST_TKJ
USING I_PERIV
LD_DAT-JAH
CHANGING S_T009 .
* Eingaben prüfen.
IF LD_DAT-MON GT CON_12 OR
LD_DAT-MON LT CON_01 OR
LD_DAT-TAG GT CON_31 OR
LD_DAT-TAG LT CON_01 OR
LD_DAT-JAH LT CON_JAHR_1800 .
MESSAGE E004 WITH I_DATE RAISING INPUT_FALSE.
ENDIF.
* Version Periodenermittlung wie Kalenderjahr ==>
* Uebernimm Periode=Monat, GJahr=Jahr und EXIT.
IF NOT S_T009-XKALE IS INITIAL.
E_BUPER = LD_DAT-MON.
E_GJAHR = LD_DAT-JAH.
* Halbperioden
IF NOT I_MONMIT IS INITIAL.
E_BUPER = E_BUPER + E_BUPER.
IF LD_DAT-TAG LT I_MONMIT.
E_BUPER = E_BUPER - 1.
ENDIF.
ENDIF.
MOVE : I_DATE TO S_DTP-DATE,
I_PERIV TO S_DTP-PERIV,
I_MONMIT TO S_DTP-MONMIT,
E_BUPER TO S_DTP-BUPER,
E_GJAHR TO S_DTP-GJAHR.
EXIT.
ENDIF.
* Version Periodenermittlung verschoben ==>
IF S_T009-XJABH EQ SPACE.
READ TABLE ST_TKJ WITH KEY PERIV = I_PERIV
BDATJ = CON_GJAHR
BUMON = LD_DAT-MON
BUTAG = LD_DAT-TAG
BINARY SEARCH.
ELSE.
READ TABLE ST_TKJ WITH KEY PERIV = I_PERIV
BDATJ = LD_DAT-JAH
BUMON = LD_DAT-MON
BUTAG = LD_DAT-TAG
BINARY SEARCH.
ENDIF.
* SUBRC = 8 kein Treffer
IF SY-SUBRC GE 8.
MESSAGE E002 WITH I_PERIV LD_DAT-JAH
RAISING T009B_NOTFOUND.
ENDIF.
* SUBRC = 4 Eintrag zu SY-TABIX passt vielleicht
IF SY-SUBRC <> 0.
READ TABLE ST_TKJ INDEX SY-TABIX.
IF SY-SUBRC <> 0 OR
ST_TKJ-PERIV <> I_PERIV .
MESSAGE E002 WITH I_PERIV LD_DAT-JAH
RAISING T009B_NOTFOUND.
ENDIF.
ENDIF.
E_BUPER = ST_TKJ-POPER.
L_GJAHR = ld_dat-jah .
CASE ST_TKJ-RELJR(1).
WHEN CON_SIGN-MINUS.
L_GJAHR = L_GJAHR - ST_TKJ-RELJR+1(1).
WHEN CON_SIGN-PLUS .
L_GJAHR = L_GJAHR + ST_TKJ-RELJR+1(1).
ENDCASE.
* Überlauf bei verschobenen Gjahr abfangen
IF L_GJAHR GE 10000 .
L_GJAHR = 9999.
E_BUPER = S_T009-ANZBP.
ENDIF.
E_GJAHR = L_GJAHR.
* Halbperioden ?
IF NOT I_MONMIT IS INITIAL AND
S_T009-ANZBP EQ CON_POPER-012.
E_BUPER = E_BUPER + E_BUPER.
MOVE I_MONMIT TO LD_DAT-TAG.
MOVE ST_TKJ-BUMON TO LD_DAT-MON.
IF I_MONMIT GT ST_TKJ-BUTAG.
IF LD_DAT-MON EQ CON_01.
LD_DAT-MON = CON_12.
LD_DAT-JAH = LD_DAT-JAH - 1.
ELSE.
LD_DAT-MON = ST_TKJ-BUMON - 1.
ENDIF.
ENDIF.
IF LD_DAT GT I_DATE.
E_BUPER = E_BUPER - 1.
ENDIF.
ENDIF.
MOVE : I_DATE TO S_DTP-DATE,
I_PERIV TO S_DTP-PERIV,
I_MONMIT TO S_DTP-MONMIT,
E_BUPER TO S_DTP-BUPER,
E_GJAHR TO S_DTP-GJAHR.
ENDFUNCTION.
*&---------------------------------------------------------------------*
*& Report ZB12_FM_CALL_33
*&
*&---------------------------------------------------------------------*
REPORT ZB12_FM_CALL_33.
parameters : p_date type sy-datum.
data : lv_first type sy-datum,
lv_last type sy-datum.
CALL FUNCTION 'Z_GET_FIRST_LAST_DAY_OF_MONTH'
EXPORTING
LV_DATE = p_date
IMPORTING
FIRST_DATE = lv_first
LAST_DATE = lv_last
.
write:/ p_date.
write:/ lv_first, lv_last.
*&---------------------------------------------------------------------*
*& Report ZB12_FM_CALL_34
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZB12_FM_CALL_34 line-size 300.
- FUNCTION MODULE SCREEN
- SE37
FUNCTION Z_DELIVERY_DATA.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(ERDAT) TYPE ERDAT
*" REFERENCE(VKORG) TYPE VKORG
*" TABLES
*" IT_FINAL STRUCTURE ZDEL
*"----------------------------------------------------------------------
select a~VBELN
a~VSTEL
a~VKORG
a~LFART
a~AUTLF
a~KUNNR
b~POSNR
b~MATNR
b~WERKS
b~LFIMG
b~VRKME
from likp as a inner join lips as b
on a~vbeln = b~vbeln
into table it_final
where a~erdat = erdat and
a~vkorg = vkorg.
ENDFUNCTION.
TCODE- SE38
parameters : p_erdat type erdat,
p_vkorg type vkorg.
data : it_delivery type standard table of ZDEL,
wa_del like line of it_delivery.
CALL FUNCTION 'Z_DELIVERY_DATA'
EXPORTING
ERDAT = p_erdat
VKORG = p_vkorg
TABLES
IT_FINAL = it_delivery
.
loop at it_delivery into wa_del.
write:/ wa_del-VBELN,
wa_del-VSTEL,
wa_del-VKORG,
wa_del-LFART,
wa_del-AUTLF,
wa_del-KUNNR,
wa_del-POSNR,
wa_del-MATNR,
wa_del-WERKS,
wa_del-LFIMG,
wa_del-VRKME.
endloop.
FUNCTIONMODULE-SE37
FUNCTION Z_GET_DEL_HEADER_ITEM.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" TABLES
*" IT_DATA STRUCTURE ZDEL
*"----------------------------------------------------------------------
TYPES: BEGIN OF LS_LIKP,
VBELN TYPE VBELN_VL,
VSTEL TYPE VSTEL,
VKORG TYPE VKORG,
LFART TYPE LFART,
AUTLF TYPE AUTLF,
KUNNR TYPE KUNWE,
END OF LS_LIKP.
DATA : IT_LIKP TYPE STANDARD TABLE OF LS_LIKP,
WA_LIKP LIKE LINE OF IT_LIKP.
FIELD-SYMBOLS : <FS_DATA> TYPE ZDEL.
IF IT_DATA[] IS NOT INITIAL.
SELECT VBELN
VSTEL
VKORG
LFART
AUTLF
KUNNR
FROM LIKP
INTO TABLE IT_LIKP FOR ALL ENTRIES IN IT_DATA
WHERE VBELN = IT_DATA-VBELN.
IF SY-SUBRC = 0.
SORT IT_LIKP BY VBELN.
ENDIF.
ENDIF.
LOOP AT IT_DATA ASSIGNING <FS_DATA>.
READ TABLE IT_LIKP INTO WA_LIKP WITH KEY VBELN = <FS_DATA>-VBELN
BINARY SEARCH.
IF SY-SUBRC = 0.
<FS_DATA>-VSTEL = WA_LIKP-VSTEL.
<FS_DATA>-VKORG = WA_LIKP-VKORG.
<FS_DATA>-LFART = WA_LIKP-LFART.
<FS_DATA>-AUTLF = WA_LIKP-AUTLF.
<FS_DATA>-KUNNR = WA_LIKP-KUNNR.
ENDIF.
ENDLOOP.
ENDFUNCTION.
PROGRAMM – SE38.
*&---------------------------------------------------------------------*
*& Report ZB12_FM_CALL_35
REPORT ZB12_FM_CALL_35 LINE-SIZE 500.
DATA : IT_FINAL TYPE STANDARD TABLE OF ZDEL,
WA_FINAL LIKE LINE OF IT_FINAL.
SELECT * FROM LIPS
INTO CORRESPONDING FIELDS OF TABLE IT_FINAL.
CALL FUNCTION 'Z_GET_DEL_HEADER_ITEM'
TABLES
IT_DATA = IT_FINAL
.
LOOP AT IT_FINAL INTO WA_FINAL.
AT FIRST.
WRITE:/ 'BEGGINING OF LOOP PROCESS'.
WRITE:/ WA_FINAL-VBELN,
WA_FINAL-VSTEL,
WA_FINAL-VKORG.
ENDAT.
AT NEW VBELN.
WRITE:/ 'NEW DOC:',
/ WA_FINAL-VBELN.
ULINE.
ENDAT.
WRITE:/ WA_FINAL-VBELN,
WA_FINAL-VSTEL,
WA_FINAL-VKORG,
WA_FINAL-LFART,
WA_FINAL-AUTLF,
WA_FINAL-KUNNR,
WA_FINAL-POSNR,
WA_FINAL-MATNR,
WA_FINAL-WERKS,
WA_FINAL-LFIMG,
WA_FINAL-VRKME.
AT LAST.
WRITE:/ 'END OF LOOP PROCESS'.
WRITE:/ WA_FINAL-VBELN,
WA_FINAL-VSTEL,
WA_FINAL-VKORG.
ENDAT.
ENDLOOP.