Skip to Content
0
Former Member
Jan 19, 2006 at 01:06 PM

delivery returns

60 Views

Hi to all,

I have a problem with Delivery Returns...

Actually Delivery Returns are marked with "X".. and it is not marked it is not delivered...

for this i need to sperate the "X" marked ones and also the non marked..

the main objective of the report is to get the NON RETURNED MATERIAL....

but problem is after returned the material it is showing me as a RETURN and also the NON RETURN....

for that i need to delete the NON RETURNED material IF IT IS RETURNED...in the report.

please go thorough the following coding and correct me...

TABLES: mara, lips, likp ,sscrfields .

type-pools: slis. "ALV Declarations

data: fieldcat type slis_t_fieldcat_alv .

data: sort type slis_t_sortinfo_alv.

data: begin of GT_ALTTEILE occurs 0,

matnr type mara-matnr, "Material Number

matkl type mara-matkl, "Material Group

vbeln type likp-vbeln, "Delivery Document Number

netpr type lips-netpr, "Net price

posnr type lips-posnr, "Delivery item

shkzg type lips-shkzg, "Returns item

extwg type mara-extwg, "

mstae type mara-mstae, "Cross-Plant Material Status

mstav type mara-mstav, "Cross-distri-chain material status

lfdat type likp-lfdat, "Delivery Date

lfart type likp-lfart, "Delivery Type

kunnr type likp-kunnr, "Ship-To Party

wadat_ist type likp-wadat_ist, "Actual goods movement date

arktx type lips-arktx, "Short Text for Sales Order Item

bismt type mara-bismt. "Old material number

data : end of GT_ALTTEILE.

data: begin of GT_RETURN occurs 0,

matnr type mara-matnr, "Material Number

vbeln type likp-vbeln, "Delivery Document Number

shkzg type lips-shkzg, "Returns item

posnr type lips-posnr. "Delivery Item

matkl type mara-matkl, "Material Group

netpr type lips-netpr, "Net price

extwg type mara-extwg, "

mstae type mara-mstae, "Cross-Plant Material Status

mstav type mara-mstav, "Cross-distri-chain material status

lfdat type likp-lfdat, "Delivery Date

lfart type likp-lfart, "Delivery Type

kunnr type likp-kunnr, "Ship-To Party

wadat_ist type likp-wadat_ist, "Actual goods movement date

arktx type lips-arktx, "Short Text for Sales Order Item

bismt type mara-bismt. "Old material number

data : end of GT_RETURN.

data : itab like table of GT_ALTTEILE with header line.

data: lv_tabix like sy-tabix.

data: gd_tab_group type slis_t_sp_group_alv with header line,

gd_layout type slis_layout_alv,

gd_repid like sy-repid,

gt_events type slis_t_event,

gd_prntparams type slis_print_alv.

select-options : s_kunnr for GT_ALTTEILE-kunnr,

s_matnr for GT_ALTTEILE-matnr,

s_lfdat for GT_ALTTEILE-lfdat,

s_extwg for GT_ALTTEILE-extwg,

s_shkzg for GT_ALTTEILE-shkzg,

s_lfart for GT_ALTTEILE-lfart,

s_matkl for GT_ALTTEILE-matkl,

s_mstae for GT_ALTTEILE-mstae,

s_mstav for GT_ALTTEILE-mstav.

START-OF-SELECTION.

perform data_retrieval.

perform build_fieldcatalog.

perform build_layout.

perform build_events.

perform build_print_params.

perform display_alv_report.

************************************************************************

*BUILD_FIELD_CATALOG

************************************************************************

form build_fieldcatalog.

data: fc_tmp type slis_t_fieldcat_alv with header line.

clear: fieldcat.

refresh: fieldcat.

clear: fc_tmp.

fc_tmp-reptext_ddic = 'Liefer.No'.

fc_tmp-fieldname = 'VBELN'.

fc_tmp-tabname = 'wa'.

fc_tmp-key = 'X'.

fc_tmp-outputlen = '18'.

fc_tmp-col_pos = 1.

  • fc_tmp-do_sum = 'X'.

  • fc_tmp-emphasize = 'C500'.

fc_tmp-hotspot = 'X'.

append fc_tmp to fieldcat.

clear: fc_tmp.

fc_tmp-reptext_ddic = 'Materialnummer'.

fc_tmp-fieldname = 'MATNR'.

fc_tmp-tabname = 'wa'.

  • fc_tmp-outputlen = '8'.

fc_tmp-col_pos = 2.

fc_tmp-key = 'X'.

  • fc_tmp-emphasize = 'C501'.

fc_tmp-hotspot = 'X'.

  • fc_tmp-do_sum = 'X'.

append fc_tmp to fieldcat.

clear: fc_tmp.

fc_tmp-reptext_ddic = 'Warengruppe'.

fc_tmp-fieldname = 'MATKL'.

  • fc_tmp-key = 'X'.

fc_tmp-tabname = 'wa'.

fc_tmp-outputlen = '5'.

fc_tmp-col_pos = 3.

  • fc_tmp-do_sum = 'X'.

append fc_tmp to fieldcat.

clear: fc_tmp.

fc_tmp-reptext_ddic = 'Bezeichnung'.

fc_tmp-fieldname = 'ARKTX'.

fc_tmp-tabname = 'wa'.

fc_tmp-outputlen = '10'.

fc_tmp-col_pos = 4.

append fc_tmp to fieldcat.

clear: fc_tmp.

fc_tmp-reptext_ddic = 'Lief posi'.

fc_tmp-fieldname = 'POSNR'.

fc_tmp-tabname = 'wa'.

fc_tmp-outputlen = '2'.

fc_tmp-col_pos = 5.

append fc_tmp to fieldcat.

clear: fc_tmp.

fc_tmp-reptext_ddic = 'Kunde'.

fc_tmp-fieldname = 'KUNNR'.

fc_tmp-tabname = 'wa'.

fc_tmp-col_pos = 6.

append fc_tmp to fieldcat.

*

  • clear: fc_tmp.

  • fc_tmp-reptext_ddic = 'Name des Kunden'.

  • fc_tmp-fieldname = 'NAME1'.

  • fc_tmp-tabname = 'wa'.

  • fc_tmp-col_pos = 7.

*

  • append fc_tmp to fieldcat.

*

*

clear: fc_tmp.

fc_tmp-reptext_ddic = 'Warenbewegsdatum'.

fc_tmp-fieldname = 'WADAT_IST'.

fc_tmp-tabname = 'wa'.

fc_tmp-col_pos = 8.

append fc_tmp to fieldcat.

clear: fc_tmp.

fc_tmp-reptext_ddic = 'Liefertermin'.

fc_tmp-fieldname = 'LFDAT'.

fc_tmp-tabname = 'wa'.

  • fc_tmp-outputlen = '18'.

fc_tmp-col_pos = 9.

append fc_tmp to fieldcat.

clear: fc_tmp.

fc_tmp-reptext_ddic = 'Lieferart'.

fc_tmp-fieldname = 'LFART'.

fc_tmp-tabname = 'wa'.

  • fc_tmp-outputlen = '6'.

fc_tmp-col_pos = 10.

append fc_tmp to fieldcat.

clear: fc_tmp.

fc_tmp-reptext_ddic = 'Externe Warengruppe'.

fc_tmp-fieldname = 'EXTWG'.

fc_tmp-tabname = 'wa'.

  • fc_tmp-outputlen = '6'.

fc_tmp-col_pos = 11.

append fc_tmp to fieldcat.

clear: fc_tmp.

fc_tmp-reptext_ddic = 'Retourenposition'.

fc_tmp-fieldname = 'SHKZG'.

fc_tmp-tabname = 'wa'.

fc_tmp-col_pos = 12.

append fc_tmp to fieldcat.

clear: fc_tmp.

fc_tmp-reptext_ddic = 'Alte Materialnummer'.

fc_tmp-fieldname = 'BISMT'.

fc_tmp-tabname = 'wa'.

  • fc_tmp-outputlen = '6'.

fc_tmp-col_pos = 13.

append fc_tmp to fieldcat.

clear: fc_tmp.

fc_tmp-reptext_ddic = 'Materialstatus'.

fc_tmp-fieldname = 'MSTAE'.

fc_tmp-tabname = 'wa'.

  • fc_tmp-outputlen = '8'.

fc_tmp-col_pos = 14.

append fc_tmp to fieldcat.

clear: fc_tmp.

fc_tmp-reptext_ddic = 'Vertriebs-status'.

fc_tmp-fieldname = 'MSTAV'.

fc_tmp-tabname = 'wa'.

  • fc_tmp-outputlen = '8'.

fc_tmp-col_pos = 15.

append fc_tmp to fieldcat.

clear: fc_tmp.

fc_tmp-reptext_ddic = 'Nettoprice'.

fc_tmp-fieldname = 'NETPR'.

fc_tmp-tabname = 'wa'.

fc_tmp-no_zero = 'X'.

  • fc_tmp-outputlen = '8'.

fc_tmp-col_pos = 16 .

fc_tmp-do_sum = 'X'.

append fc_tmp to fieldcat.

endform.

&----


*& Form BUILD_LAYOUT

&----


  • Build layout for ALV grid report

----


form build_layout.

gd_layout-no_input = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-totals_text = 'Totals'(201).

gd_layout-totals_only = 'X'.

  • gd_layout-f2code = 'DISP'. "Sets fcode for when double

  • "click(press f2)

gd_layout-info_fieldname = 'LINE_COLOR'.

gd_layout-info_fieldname = 'WS_COLOR'.

gd_layout-zebra = 'X'.

gd_layout-group_change_edit = 'X'.

gd_layout-header_text = 'HELLO'.

endform. " BUILD_LAYOUT

&----


*& Form DISPLAY_ALV_REPORT

&----


  • Display report using ALV grid

----


form display_alv_report.

gd_repid = sy-repid.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = gd_repid

i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM

i_callback_user_command = 'USER_COMMAND'

  • i_grid_title = outtext

is_layout = gd_layout

it_fieldcat = fieldcat

it_sort = sort

  • it_special_groups = gd_tabgroup

it_events = gt_events

is_print = gd_prntparams

i_save = 'X'

  • is_variant = z_template

tables

t_outtab = itab

exceptions

program_error = 1

others = 2.

endform. " DISPLAY_ALV_REPORT

&----


*& Form DATA_RETRIEVAL

&----


  • Retrieve data form VBAK table and populate itab it_VBAK

----


form data_retrieval.

data: ld_color(1) type C.

select mara~matnr

mara~matkl

likp~vbeln

lips~netpr

lips~posnr

lips~shkzg

mara~extwg

mara~mstae

mara~mstav

likp~lfdat

likp~lfart

likp~kunnr

likp~wadat_ist

lips~arktx

mara~bismt

into corresponding fields of table itab from lips

inner join likp

on lipsvbeln = likpvbeln

inner join mara

on lipsmatnr = maramatnr

where likp~kunnr in s_kunnr

and mara~matnr in s_matnr

and lips~shkzg in s_shkzg

and likp~lfart in s_lfart

and lips~matkl in s_matkl

and likp~lfdat in s_lfdat

and mara~extwg in s_extwg

and mara~mstav in s_mstav

and mara~mstae in s_mstae.

LOOP AT ITAB.

LV_TABIX = SY-TABIX.

READ TABLE GT_RETURN WITH KEY VBELN = GT_ALTTEILE-VBELN.

IF SY-SUBRC = 0.

DELETE ITAB INDEX LV_TABIX.

ENDIF.

ENDLOOP.

endform. " DATA_RETRIEVAL

Thanks in advance

Raju.