0% found this document useful (0 votes)
362 views13 pages

Z Phy Inv Document

This program displays physical inventory documents from tables in the SAP system. It reads data from inventory documents and material master tables, processes the data, and displays a report. The program was created in 2006 by Rajkumar Abbu of IBM to display physical inventory documents in SAP's materials management module.

Uploaded by

api-3703552
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
362 views13 pages

Z Phy Inv Document

This program displays physical inventory documents from tables in the SAP system. It reads data from inventory documents and material master tables, processes the data, and displays a report. The program was created in 2006 by Rajkumar Abbu of IBM to display physical inventory documents in SAP's materials management module.

Uploaded by

api-3703552
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 13

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

*&program name: displaying the physical inventoy documents *


*&sapname: z_phy_inv_document *
*&creation date: 06/02/2006 *
*&application: mm *
*&author: rajkumar abbu *
*& ibm business consulting services *
*&---------------------------------------------------------------------*
*&desc: this report is used to display the *
*& physical inventory documents *
*&---------------------------------------------------------------------*
*&type: 1 - 'executable program ' *
*&inputs: selection-screen *
*&outputs: physical inventory doc list *
*&external routines: n/a *
*&---------------------------------------------------------------------*
*& m o d i f i c a t i o n l o g *
*&---------------------------------------------------------------------*
*& date | mod # | developer | description
*&----------|----------|--------------|--------------------------------*
*& 06/02/06 |rd0k905577|rajkumar abbu | initial construction *
*&---------------------------------------------------------------------*

report z_phy_inv_document
message-id zmm no standard page heading .

*---------------------------------------------------------------------
* tables
*---------------------------------------------------------------------
tables : ikpf.

*--------------------------------------------------------------------
* type-pool declarations
*--------------------------------------------------------------------
type-pools : slis.

*--------------------------------------------------------------------
* types declaration
*--------------------------------------------------------------------

types : begin of type_phydocu,


werks type ikpf-werks,
lgort type ikpf-lgort,
iblnr type ikpf-iblnr,
gjahr type ikpf-gjahr,
bldat type ikpf-bldat,
gidat type ikpf-gidat,
invnu type ikpf-invnu,
xblni type ikpf-xblni,
zstat type ikpf-zstat,
zeili type iseg-zeili,
matnr type iseg-matnr,
meins type iseg-meins,
charg type iseg-charg,
bstar type iseg-bstar,
buchm type iseg-buchm,
end of type_phydocu.
types : begin of type_mat,
matnr type makt-matnr,
maktx type makt-maktx,
end of type_mat.

types : begin of type_batch,


matnr type iseg-matnr,
charg type iseg-charg,
atwrt type ausp-atwrt,
end of type_batch.

types : begin of type_werks,


werks type t001w-werks,
end of type_werks.

types : begin of type_lgort,


werks type t001l-lgort,
end of type_lgort.

types : begin of type_iblnr,


werks type ikpf-iblnr,
end of type_iblnr.

types : begin of type_final,


werks type ikpf-werks,
lgort type ikpf-lgort,
iblnr type ikpf-iblnr,
zeili type iseg-zeili,
matnr type iseg-matnr,
maktx type makt-maktx,
meins type iseg-meins,
charg type iseg-charg,
atwrt type ausp-atwrt,
bstar type iseg-bstar,
buchm type iseg-buchm,
gjahr type ikpf-gjahr,
bldat type ikpf-bldat,
gidat type ikpf-gidat,
invnu type ikpf-invnu,
xblni type ikpf-xblni,
zstat type ikpf-zstat,
end of type_final.

*-------------------------------------------------------------------
* internal tables
*-------------------------------------------------------------------
data : gi_phydocu type table of type_phydocu,
gi_mat type table of type_mat,
gi_batch type table of type_batch,
gi_final type table of type_final,
gi_iblnr type table of type_iblnr, "#ec needed
gi_werks type table of type_werks, "#ec needed
gi_lgort type table of type_lgort, "#ec needed
gi_fcat type slis_t_fieldcat_alv,
gi_event type slis_t_event,
gi_list_header type slis_t_listheader.
*-------------------------------------------------------------------
* constants
*-------------------------------------------------------------------

constants : c_reel_sn type atnam value 'reel_sn',


c_klart type klassenart value '023'.

*----------------------------------------------------------------------
* selection-screen
*----------------------------------------------------------------------

selection-screen begin of block f1 with frame title text-001.

select-options : s_iblnr for ikpf-iblnr,


s_gjahr for ikpf-gjahr obligatory,
s_werks for ikpf-werks obligatory,
s_lgort for ikpf-lgort,
s_bldat for ikpf-bldat,
s_gidat for ikpf-gidat,
s_invnu for ikpf-invnu,
s_xblni for ikpf-xblni,
s_zstat for ikpf-zstat.

selection-screen end of block f1.

*----------------------------------------------------------------------
* at selection-screen
*-----------------------------------------------------------------------
at selection-screen on s_iblnr.

if not s_iblnr is initial.


select iblnr from ikpf into table gi_iblnr where iblnr in s_iblnr.
if sy-subrc <> 0.
message e048 with text-022.
endif.
endif.

at selection-screen on s_werks.

select werks from t001w into table gi_werks where werks in s_werks.
if sy-subrc <> 0.
message e163.
endif.

at selection-screen on s_lgort.

if not s_lgort is initial.


select lgort from t001l into table gi_lgort where lgort in s_lgort.
if sy-subrc <> 0.
message e165.
endif.
endif.

at selection-screen on s_gjahr.

if s_gjahr-low > sy-datum+0(4).


message e048 with text-023.
endif.

*-----------------------------------------------------------------------
* start-of-selection
*-----------------------------------------------------------------------
start-of-selection.

perform sub_read_data.
perform sub_process_data.

*-----------------------------------------------------------------------
* end-of-selection
*-----------------------------------------------------------------------
end-of-selection.

perform sub_display_report using gi_final.

*&---------------------------------------------------------------------*
*& form sub_read_data
*&---------------------------------------------------------------------*

form sub_read_data .

*read physical inventory data from ikpf and iseg


perform sub_read_phydocu changing gi_phydocu.

*read the material description from makt


perform sub_read_mat using gi_phydocu
changing gi_mat.
*read the serial number
perform sub_read_batch using gi_phydocu
changing gi_batch.

endform. " sub_read_data


*&---------------------------------------------------------------------*
*& form sub_read_phydocu
*&---------------------------------------------------------------------*
* read table ikpf and iseg
*----------------------------------------------------------------------*
* -->li_phydocu
*----------------------------------------------------------------------*
form sub_read_phydocu changing li_phydocu like gi_phydocu.

select a~werks
a~lgort
a~iblnr
a~gjahr
a~bldat
a~gidat
a~invnu
a~xblni
a~zstat
b~zeili
b~matnr
b~meins
b~charg
b~bstar
b~buchm
from ( ikpf as a inner join iseg as b on
a~iblnr = b~iblnr and
a~gjahr = b~gjahr )
into table li_phydocu
where a~iblnr in s_iblnr and
a~gjahr in s_gjahr and
a~werks in s_werks and
a~lgort in s_lgort and
a~bldat in s_bldat and
a~gidat in s_gidat and
a~invnu in s_invnu and
a~xblni in s_xblni and
a~zstat in s_zstat.

endform. " sub_read_phydocu


*&---------------------------------------------------------------------*
*& form sub_read_mat
*&---------------------------------------------------------------------*
* read makt table
*----------------------------------------------------------------------*
* -->li_phydocu
* <--li_mat
*----------------------------------------------------------------------*
form sub_read_mat using li_phydocu like gi_phydocu
changing li_mat like gi_mat.

data : li_phydocu1 type table of type_phydocu.

li_phydocu1[] = li_phydocu[].
sort li_phydocu1 by matnr.
delete adjacent duplicates from li_phydocu1 comparing matnr.

if li_phydocu1 is not initial.


select matnr
maktx
from makt
into table li_mat
for all entries in li_phydocu1
where matnr = li_phydocu1-matnr.

if sy-subrc = 0.
sort li_mat by matnr.
endif.

endif.

refresh li_phydocu1[].

endform. " sub_read_mat


*&---------------------------------------------------------------------*
*& form sub_read_batch
*&---------------------------------------------------------------------*
* read serial number
*----------------------------------------------------------------------*
* -->li_phydocu text
* <--li_batch text
*----------------------------------------------------------------------*
form sub_read_batch using li_phydocu like gi_phydocu
changing li_batch like gi_batch.

types : begin of type_objkey,


matnr type iseg-matnr,
charg type iseg-matnr,
objek type inob-objek,
end of type_objkey.

types : begin of type_inob,


cuobj type ausp-objek,
objek type inob-objek,
end of type_inob.

types : begin of type_ausp,


objek type ausp-objek,
atwrt type ausp-atwrt,
end of type_ausp.

data : li_phydocu1 type table of type_phydocu,


lw_phydocu1 type type_phydocu,
li_objkey type table of type_objkey,
lw_objkey type type_objkey,
li_inob type table of type_inob,
lw_inob type type_inob,
li_ausp type table of type_ausp,
lw_ausp type type_ausp,
lw_batch type type_batch.

data : lv_atinn type atinn.

li_phydocu1[] = li_phydocu[].
delete li_phydocu1 where charg is initial.
sort li_phydocu1 by matnr charg.
delete adjacent duplicates from li_phydocu1 comparing matnr charg.

loop at li_phydocu1 into lw_phydocu1.

lw_objkey-matnr = lw_phydocu1-matnr.
lw_objkey-charg = lw_phydocu1-charg.
lw_objkey-objek+0(18) = lw_phydocu1-matnr.
lw_objkey-objek+18 = lw_phydocu1-charg.
append lw_objkey to li_objkey.
clear : lw_phydocu1,lw_objkey.

endloop.

if not li_objkey is initial.

* read inob table for object key


select cuobj
objek
from inob
into table li_inob
for all entries in li_objkey
where klart = c_klart and
obtab = 'mch1' and
objek = li_objkey-objek.

if sy-subrc = 0.
sort li_inob by objek.
endif.

endif.

* read cabn table for serial number characterstic value


select single atinn
from cabn
into lv_atinn
where atnam = c_reel_sn. "#ec *

if not li_inob is initial.

* read ausp table for characterstic value of serial number


select objek
atwrt
from ausp
into table li_ausp
for all entries in li_inob
where objek = li_inob-cuobj and
atinn = lv_atinn and
klart = c_klart.

if sy-subrc = 0.
sort li_ausp by objek.
endif.

endif.

loop at li_objkey into lw_objkey.

read table li_inob into lw_inob


with key objek = lw_objkey-objek binary search .

if sy-subrc = 0.

read table li_ausp into lw_ausp


with key objek = lw_inob-cuobj binary search.

if sy-subrc = 0.

lw_batch-matnr = lw_objkey-matnr.
lw_batch-charg = lw_objkey-charg.
lw_batch-atwrt = lw_ausp-atwrt.

append lw_batch to li_batch.


clear : lw_batch,lw_ausp,lw_inob,lw_objkey.

endif.

endif.

endloop.
sort li_batch by matnr charg.

refresh : li_phydocu1[],li_objkey[],li_inob[],li_ausp[].

endform. " sub_read_batch


*&---------------------------------------------------------------------*
*& form sub_process_data
*&---------------------------------------------------------------------*
* prepare the final internal table
*----------------------------------------------------------------------*
form sub_process_data .

data : lw_mat type type_mat,


lw_batch type type_batch,
lw_phydocu type type_phydocu,
lw_final type type_final.

loop at gi_phydocu into lw_phydocu.

lw_final-werks = lw_phydocu-werks.
lw_final-lgort = lw_phydocu-lgort.
lw_final-iblnr = lw_phydocu-iblnr.
lw_final-zeili = lw_phydocu-zeili.
lw_final-matnr = lw_phydocu-matnr.
lw_final-meins = lw_phydocu-meins.
lw_final-charg = lw_phydocu-charg.
lw_final-bstar = lw_phydocu-bstar.
lw_final-buchm = lw_phydocu-buchm.
lw_final-gjahr = lw_phydocu-gjahr.
lw_final-bldat = lw_phydocu-bldat.
lw_final-gidat = lw_phydocu-gidat.
lw_final-invnu = lw_phydocu-invnu.
lw_final-xblni = lw_phydocu-xblni.
lw_final-zstat = lw_phydocu-zstat.

read table gi_mat into lw_mat


with key matnr = lw_phydocu-matnr binary search.
if sy-subrc = 0.
lw_final-maktx = lw_mat-maktx.
endif.

read table gi_batch into lw_batch


with key matnr = lw_phydocu-matnr
charg = lw_phydocu-charg binary search.

if sy-subrc = 0.
lw_final-atwrt = lw_batch-atwrt.
endif.

append lw_final to gi_final.


clear : lw_final,lw_phydocu,lw_mat,lw_batch.
endloop.
endform. " sub_process_data
*&---------------------------------------------------------------------*
*& form sub_display_report
*&---------------------------------------------------------------------*
* display the report output
*----------------------------------------------------------------------*
* -->p_gi_final
*----------------------------------------------------------------------*
form sub_display_report using li_final like gi_final.

perform sub_fill_fieldcat changing gi_fcat.


perform sub_fill_event changing gi_event.
perform sub_fill_listheaer.
perform sub_display_list using li_final gi_fcat gi_event.

endform. " sub_display_report


*&---------------------------------------------------------------------*
*& form sub_fill_fieldcat
*&---------------------------------------------------------------------*
* prepare the field catalog
*----------------------------------------------------------------------*
* <--p_gi_fcat
*----------------------------------------------------------------------*
form sub_fill_fieldcat changing li_fcat like gi_fcat.

data lw_fcat type slis_fieldcat_alv.

lw_fcat-fieldname = 'werks'.
lw_fcat-tabname = 'gi_final'.
lw_fcat-seltext_m = text-003.
lw_fcat-outputlen = '5'.
append lw_fcat to li_fcat.
clear lw_fcat.

lw_fcat-fieldname = 'lgort'.
lw_fcat-tabname = 'gi_final'.
lw_fcat-seltext_m = text-004.
lw_fcat-outputlen = '4'.
append lw_fcat to li_fcat.
clear lw_fcat.

lw_fcat-fieldname = 'iblnr'.
lw_fcat-tabname = 'gi_final'.
lw_fcat-seltext_m = text-005.
lw_fcat-outputlen = '10'.
append lw_fcat to li_fcat.
clear lw_fcat.

lw_fcat-fieldname = 'zeili'.
lw_fcat-tabname = 'gi_final'.
lw_fcat-seltext_m = text-006.
lw_fcat-outputlen = '3'.
append lw_fcat to li_fcat.
clear lw_fcat.

lw_fcat-fieldname = 'matnr'.
lw_fcat-tabname = 'gi_final'.
lw_fcat-seltext_m = text-007.
lw_fcat-outputlen = '18'.
append lw_fcat to li_fcat.
clear lw_fcat.

lw_fcat-fieldname = 'maktx'.
lw_fcat-tabname = 'gi_final'.
lw_fcat-seltext_m = text-008.
lw_fcat-outputlen = '40'.
append lw_fcat to li_fcat.
clear lw_fcat.

lw_fcat-fieldname = 'meins'.
lw_fcat-tabname = 'gi_final'.
lw_fcat-seltext_m = text-009.
lw_fcat-outputlen = '3'.
append lw_fcat to li_fcat.
clear lw_fcat.

lw_fcat-fieldname = 'charg'.
lw_fcat-tabname = 'gi_final'.
lw_fcat-seltext_m = text-010.
lw_fcat-outputlen = '10'.
append lw_fcat to li_fcat.
clear lw_fcat.

lw_fcat-fieldname = 'atwrt'.
lw_fcat-tabname = 'gi_final'.
lw_fcat-seltext_m = text-011.
lw_fcat-outputlen = '30'.
append lw_fcat to li_fcat.
clear lw_fcat.

lw_fcat-fieldname = 'bstar'.
lw_fcat-tabname = 'gi_final'.
lw_fcat-seltext_m = text-012.
lw_fcat-outputlen = '1'.
append lw_fcat to li_fcat.
clear lw_fcat.

lw_fcat-fieldname = 'buchm'.
lw_fcat-tabname = 'gi_final'.
lw_fcat-seltext_m = text-013.
lw_fcat-outputlen = '13'.
append lw_fcat to li_fcat.
clear lw_fcat.

lw_fcat-fieldname = 'gjahr'.
lw_fcat-tabname = 'gi_final'.
lw_fcat-seltext_m = text-014.
lw_fcat-no_out = 'x'.
lw_fcat-outputlen = '4'.
append lw_fcat to li_fcat.
clear lw_fcat.

lw_fcat-fieldname = 'bldat'.
lw_fcat-tabname = 'gi_final'.
lw_fcat-seltext_m = text-015.
lw_fcat-no_out = 'x'.
lw_fcat-outputlen = '8'.
append lw_fcat to li_fcat.
clear lw_fcat.

lw_fcat-fieldname = 'gidat'.
lw_fcat-tabname = 'gi_final'.
lw_fcat-seltext_m = text-016.
lw_fcat-outputlen = '18'.
lw_fcat-no_out = 'x'.
append lw_fcat to li_fcat.
clear lw_fcat.

lw_fcat-fieldname = 'invnu'.
lw_fcat-tabname = 'gi_final'.
lw_fcat-seltext_m = text-017.
lw_fcat-outputlen = '16'.
lw_fcat-no_out = 'x'.
append lw_fcat to li_fcat.
clear lw_fcat.

lw_fcat-fieldname = 'xblni'.
lw_fcat-tabname = 'gi_final'.
lw_fcat-seltext_m = text-018.
lw_fcat-outputlen = '16'.
lw_fcat-no_out = 'x'.
append lw_fcat to li_fcat.
clear lw_fcat.

lw_fcat-fieldname = 'zstat'.
lw_fcat-tabname = 'gi_final'.
lw_fcat-seltext_m = text-019.
lw_fcat-outputlen = '1'.
lw_fcat-no_out = 'x'.
append lw_fcat to li_fcat.
clear lw_fcat.

endform. " sub_fill_fieldcat


*&---------------------------------------------------------------------*
*& form sub_fill_event
*&---------------------------------------------------------------------*
* prepare the event internal table
*----------------------------------------------------------------------*
* <--p_gi_event
*----------------------------------------------------------------------*
form sub_fill_event changing li_event like gi_event.

data : lw_event type slis_alv_event,


c_formname_top_of_page type slis_formname value 'top_of_page'.

call function 'reuse_alv_events_get'


exporting
i_list_type = 0
importing
et_events = li_event.

read table li_event with key name = slis_ev_top_of_page


into lw_event.
if sy-subrc = 0.
move c_formname_top_of_page to lw_event-form.
append lw_event to li_event.
endif.
clear lw_event.

endform. " sub_fill_event


*&---------------------------------------------------------------------*
*& form sub_fill_listheaer
*&---------------------------------------------------------------------*
* prepare the list header internal table
*----------------------------------------------------------------------*
form sub_fill_listheaer .

data : lw_line type slis_listheader,


lv_date(10),
lv_time(10).
clear lw_line.
lw_line-typ = 'h'.
lw_line-info = text-002.
append lw_line to gi_list_header.

clear lw_line.

lw_line-typ = 's'.
lw_line-key = text-020.
lw_line-info = sy-uname.
append lw_line to gi_list_header.
clear lw_line.

* lv_date = sy-datum.
write : sy-datum to lv_date dd/mm/yyyy.
lw_line-typ = 's'.
lw_line-key = text-021.
lw_line-info = lv_date.
append lw_line to gi_list_header.
clear lw_line.

* lv_time = sy-uzeit.
write : sy-uzeit to lv_time using edit mask '__:__:__'.
lw_line-typ = 's'.
lw_line-key = text-024.
lw_line-info = lv_time.
append lw_line to gi_list_header.
clear lw_line.

endform. " sub_fill_listheaer


*&---------------------------------------------------------------------*
*& form sub_display_list
*&---------------------------------------------------------------------*
* call the function module for output display
*----------------------------------------------------------------------*
* -->p_li_final
* -->p_gi_fcat
* -->p_gi_event
*----------------------------------------------------------------------*
form sub_display_list using li_final like gi_final
li_fcat like gi_fcat
li_event like gi_event.
data : l_repid type sy-repid.
data: l_layout type slis_layout_alv.
l_repid = sy-repid.

l_layout-zebra = 'x'.

if not li_final[] is initial.


call function 'reuse_alv_grid_display'
exporting
i_callback_program = l_repid
it_fieldcat = li_fcat[]
is_layout = l_layout
it_events = li_event[]
tables
t_outtab = li_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.
else.
message s048 with 'no data available'.
endif.

clear : li_fcat[],li_event[],gi_list_header[].

endform. " sub_display_list

*-----------------------------------------------------------------------
* top_of_page
*----------------------------------------------------------------------
form top_of_page. "#ec called

call function 'reuse_alv_commentary_write'


exporting
it_list_commentary = gi_list_header.

endform. "top_of_page

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy