cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a billing category is EQ L for del rel.. else bill cat NE L order related in vf04

0 Kudos

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

*& Report ZPENDING_ORDER_DEL_REPORT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZPENDING_ORDER_DEL_REPORT.

tables : VKDFS ,vbpa , kna1 ,adrc ,lips .
type-pools : slis.
*-------------------------------------------------------------------
types : begin of ty_vkdfs ,
FKDAT type vkdfs-FKDAT,
FKART type vkdfs-FKART,
VBTYP type vkdfs-VBTYP,
vkorg type vkdfs-vkorg,
VTWEG type vkdfs-VTWEG,
SPART type vkdfs-SPART,
kunnr type vkdfs-kunnr ,
WAERK type vkdfs-WAERK ,
FKTYP type vkdfs-FKTYP ,
VBELN type vkdfs-VBELN ,
end of ty_vkdfs .

types : begin of ty_kna1,
kunnr type kna1-kunnr,
name1 type kna1-name1,
adrnr type kna1-adrnr,
stcd3 type kna1-stcd3,
end of ty_kna1.

types : begin of ty_adrc,
ADDRNUMBER type ad_addrnum,
HOUSE_NUM1 type ad_hsnm1,
STR_SUPPL1 type AD_STRSPP1,
city1 type ad_city1,
POST_CODE1 type ad_pstcd1,
REGION type regio,
end of ty_adrc.

types : begin of ty_lips ,
WERKS type vbap-WERKS ,
vbeln type vbap-vbeln ,
end of ty_lips.

types : begin of x_final ,
FKDAT type FKDAT ,
FKART type FKART ,
VBTYP type VBTYP ,
vkorg type vkorg ,
VTWEG type VTWEG ,
SPART type SPART ,
WAERK type WAERK ,
FKTYP type FKTYP ,

WERKS type LIPS-WERKS ,
vbeln type lips-vbeln ,
aubel type vbrp-aubel ,
parvw type vbpa-parvw ,
kunnr type kna1-kunnr,
name1 type kna1-name1,
adrnr type kna1-adrnr,
stcd3 type kna1-stcd3,
ADDRNUMBER type adrc-addrnumber,
HOUSE_NUM1 type adrc-HOUSE_NUM1,
STR_SUPPL1 type adrc-STR_SUPPL1 ,
city1 type adrc-city1,
POST_CODE1 type adrc-POST_CODE1,
REGION type adrc-REGION ,

end of x_final .

*----------------datadceclareation-----------------------------------------------

data : i_vkdfs type STANDARD TABLE OF ty_vkdfs with header line,
i_kna1 type STANDARD TABLE OF ty_kna1 with header line ,
i_adrc type STANDARD TABLE OF ty_adrc with header line ,
i_lips type STANDARD TABLE OF ty_lips with header line ,
i_final type STANDARD TABLE OF x_final with header line ,
i_vbrk type STANDARD TABLE OF vbrk with header line ,
i_vbrp type standard table of vbrp with header line .


data : wa_vkdfs type ty_vkdfs ,
wa_final type x_final ,
wa_kna1 type ty_kna1 ,
wa_adrc type ty_adrc,
wa_lips type ty_lips ,
wa_vbrk type vbrk ,
wa_vbrp type vbrp .



data : it_fieldcat type slis_t_fieldcat_alv,
wa_fieldcat type slis_fieldcat_alv,
wa_layout type slis_layout_alv.

data : v_delrel type c length 10 ,
v_ordrel type c length 20 ,
v_cntr type i.

*-----------selectionscreen----------------------------------------------------

SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001 .
select-OPTIONS : s_fkdat for vkdfs-fkdat ,
s_fkart for vkdfs-fkart ,
s_vbtyp for vkdfs-vbtyp ,
s_vkorg for vkdfs-vkorg ,
s_vtweg for vkdfs-vtweg ,
s_spart for vkdfs-spart ,
s_plant for lips-werks .

SELECTION-SCREEN : END OF BLOCK b1 .

SELECTION-SCREEN : begin of BLOCK b2 with FRAME TITLE text-002 .
PARAMETERS : p_1 RADIOBUTTON GROUP r1 , " delivary related
p_2 RADIOBUTTON GROUP r1 . " order related

SELECTION-SCREEN : end of BLOCK b2 .

perform del_rel .

perform alv_dis .




*------------------endofscreen--------------------------------------------------

*&---------------------------------------------------------------------*
*& Form DEL_REL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DEL_REL .


if p_1 = 'X' .
v_delrel = 'L'.
elseif p_2 = 'X'.
v_ordrel = 'A'.
endif.




select fkdat
fkart
vbtyp
vkorg
vtweg
spart
kunnr
WAERK
FKTYP
VBELN
from vkdfs into table i_vkdfs
where fkdat in s_fkdat
and fkart in s_fkart
and vbtyp in s_vbtyp
and vkorg in s_vkorg
and vtweg in s_vtweg
and spart in s_spart and FKTYP eq v_delrel.

IF sy-subrc eq 0.
DESCRIBE TABLE i_vkdfs lines v_cntr .
else .
MESSAGE E398(00) WITH 'No Records'.
ENDIF.


if i_vkdfs[] is not initial.

select kunnr
name1
adrnr
from kna1 into table i_kna1
for all entries in i_vkdfs
where kunnr eq i_vkdfs-kunnr.
*
* select WERKS
* vbeln
* from lips into table i_lips
* for all entries in i_vkdfs
* where vbeln eq i_vkdfs-vbeln .

select SINGLE werks
from lips into i_lips
where vbeln eq i_vkdfs-vbeln .


endif .

if i_kna1[] is not initial .

select ADDRNUMBER
HOUSE_NUM1
STR_SUPPL1
CITY1
POST_CODE1
REGION

from adrc into table i_adrc
for all entries in i_kna1
where addrnumber eq i_kna1-adrnr .




endif .


LOOP AT i_vkdfs into wa_vkdfs .
read table i_kna1 into wa_kna1 with key kunnr = wa_vkdfs-kunnr .
read table i_lips into wa_lips with key vbeln = wa_vkdfs-vbeln .
read table i_adrc into wa_adrc with key addrnumber = wa_kna1-adrnr .



i_final-fkdat = wa_vkdfs-fkdat .
i_final-fkart = wa_vkdfs-fkart .
i_final-VBELN = wa_vkdfs-VBELN .
i_final-FKTYP = wa_vkdfs-FKTYP .
i_final-vkorg = wa_vkdfs-vkorg .
i_final-vtweg = wa_vkdfs-vtweg .
i_final-spart = wa_vkdfs-spart .
i_final-kunnr = wa_vkdfs-kunnr .
i_final-name1 = wa_kna1-name1 .
i_final-werks = wa_lips-werks .
i_final-str_suppl1 = wa_adrc-str_suppl1 .
i_final-city1 = wa_adrc-city1 .

append i_final .
clear i_final .
ENDLOOP.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form ALV_DIS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ALV_DIS .

clear wa_fieldcat.
clear it_fieldcat.
clear wa_layout.

wa_fieldcat-seltext_m = 'date'.
wa_fieldcat-fieldname = 'FKDAT'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.

wa_fieldcat-seltext_m = 'Billing type'.
wa_fieldcat-fieldname = 'FKART'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.

wa_fieldcat-seltext_m = 'sales doc'.
wa_fieldcat-fieldname = 'VBELN'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.

wa_fieldcat-seltext_m = 'Billing cat'.
wa_fieldcat-fieldname = 'FKTYP'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.

wa_fieldcat-seltext_m = 'sales orag'.
wa_fieldcat-fieldname = 'VKORG'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.

wa_fieldcat-seltext_m = 'Distribution Channel'.
wa_fieldcat-fieldname = 'VTWEG'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.

wa_fieldcat-seltext_m = 'plant'.
wa_fieldcat-fieldname = 'WERKS'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.


wa_fieldcat-seltext_m = 'slod-to-party'.
wa_fieldcat-fieldname = 'KUNNR'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.


wa_fieldcat-seltext_m = 'Division'.
wa_fieldcat-fieldname = 'SPART'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.

wa_fieldcat-seltext_m = 'Name'.
wa_fieldcat-fieldname = 'NAME1'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.

wa_fieldcat-seltext_m = 'Street'.
wa_fieldcat-fieldname = 'STR_SUPPL1'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.

wa_fieldcat-seltext_m = 'city'.
wa_fieldcat-fieldname = 'CITY1'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.

*--------------------------------------------------------------------
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = sy-repid
it_fieldcat = it_fieldcat
is_layout = wa_layout

tables
t_outtab = i_final
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.

FredericGirod
Active Contributor
0 Kudos

Pseudo code in title

not using CODE to display your code

no question in the message

...

Accepted Solutions (0)

Answers (0)