*Types
types:
begin of ty_cdhdr,
objectclas like cdhdr-objectclas, " Object class
objectid like cdhdr-objectid, " Object value
changenr like cdhdr-changenr, " Document change number
username like cdhdr-username, " Changed by
udate like cdhdr-udate, " Changed on
utime like cdhdr-utime, " Changed at
tcode like cdhdr-tcode, " Transaction code
end of ty_cdhdr,
ty_it_cdhdr type ty_cdhdr occurs 0,
begin of ty_cdpos,
objectclas like cdpos-objectclas, " Object class
objectid like cdpos-objectid, " Object value
changenr like cdpos-changenr, " Document change number
tabname like cdpos-tabname, " Table name
tabkey like cdpos-tabkey, " Table key
fname like cdpos-fname, " Field name
chngind like cdpos-chngind, " Change indicator
value_new like cdpos-value_new, " New value of field
value_old like cdpos-value_old, " Old value of field
end of ty_cdpos,
ty_it_cdpos type ty_cdpos occurs 0,
begin of ty_dd03l,
tabname like dd03l-tabname,
fieldname like dd03l-fieldname,
as4local like dd03l-as4local,
as4vers like dd03l-as4vers,
rollname like dd03l-rollname,
end of ty_dd03l,
ty_it_dd03l type ty_dd03l occurs 0,
begin of ty_dd04t,
rollname like dd04t-rollname,
ddlanguage like dd04t-ddlanguage,
as4local like dd04t-as4local,
as4vers like dd04t-as4vers,
scrtext_l like dd04t-scrtext_l,
end of ty_dd04t,
ty_it_dd04t type ty_dd04t occurs 0,
begin of ty_kna1,
kunnr like kna1-kunnr, " Customer number
name1 like kna1-name1, " Customer name
end of ty_kna1,
ty_it_kna1 type ty_kna1 occurs 0,
ty_text(500) type c,
ty_lines type tline,
ty_it_lines type ty_lines occurs 0,
begin of ty_merged,
vbeln like vbak-vbeln, " Sales order number
erdat like vbak-erdat, " Created on
auart like vbak-auart, " Order type
faksk like vbak-faksk, " Billing block in SD document
netwr like vbak-netwr, " Net value
waerk like vbak-waerk, " Currency
vkorg like vbak-vkorg, " Sales organisation
vtweg like vbak-vtweg, " Distribution channel
vkbur like vbak-vkbur, " Sales office
fkara like vbak-fkara, " Proposed billing type
kunnr like vbak-kunnr, " Sold-to party
xblnr like vbak-xblnr, " Reference
fbuda like vbkd-fbuda, " Date services rendered
username like cdhdr-username, " Changed by
udate like cdhdr-udate, " Changed on
utime like cdhdr-utime, " Changed at
tcode like cdhdr-tcode, " Transaction code
tabname like cdpos-tabname, " Table name
tabkey like cdpos-tabkey, " Table key
fname like cdpos-fname, " Field name
chngind like cdpos-chngind, " Change indicator
value_new like cdpos-value_new, " New value of field
value_old like cdpos-value_old, " Old value of field
scrtext_l like dd04t-scrtext_l, " Description of field
intnote type ty_text, " Internal note
hdrnote type ty_text, " Header note
name1 like adrc-name1, " Sold-to party name
end of ty_merged,
ty_it_merged type ty_merged occurs 0,
begin of ty_vbak,
vbeln like vbak-vbeln, " Sales order number
erdat like vbak-erdat, " Created on
auart like vbak-auart, " Order type
faksk like vbak-faksk, " Billing block in SD document
netwr like vbak-netwr, " Net value
waerk like vbak-waerk, " Currency
vkorg like vbak-vkorg, " Sales organisation
vtweg like vbak-vtweg, " Distribution channel
vkbur like vbak-vkbur, " Sales office
fkara like vbak-fkara, " Proposed billing type
kunnr like vbak-kunnr, " Sold-to party
xblnr like vbak-xblnr, " Reference
objectid like cdhdr-objectid, " Change document object
end of ty_vbak,
ty_it_vbak type ty_vbak occurs 0,
begin of ty_vbkd,
vbeln like vbkd-vbeln, " Sales order number
posnr like vbkd-posnr, " Sales order item
fbuda like vbkd-fbuda, " Date services rendered
end of ty_vbkd,
ty_it_vbkd type ty_vbkd occurs 0.
*Internal tables
data:
it_cdhdr type ty_it_cdhdr,
it_cdpos type ty_it_cdpos,
it_fieldcat type slis_t_fieldcat_alv,
it_kna1 type ty_it_kna1,
it_merged type ty_it_merged,
it_vbak type ty_it_vbak,
it_vbkd type ty_it_vbkd.
data:
wa_vbak type ty_vbak.
data:
st_tvariant like disvariant,
st_variant like disvariant.
constants:
co_as4local_a like dd03l-as4local " Active version
value 'A',
co_objectclas_verkbeleg like cdhdr-objectclas
value 'VERKBELEG',
co_posnr_initial like vbkd-posnr " Initial item number
value is initial,
co_save_u type c " User display variant
value 'U', " saving allowed.
co_trvog_0 like vbak-trvog " Sales order
value '0'.
data:
va_exit type c, " ALV display
va_tabix like sy-tabix.
selection-screen: begin of block b1 with frame title text-001.
parameters: s_vkbur like vbak-vkbur.
"s_vkorg like vbak-vkbur,
"s_vtweg like vbak-vkbur.
select-options:
" s_vkbur for vbak-vkbur, " Sales office
"s_vkorg for vbak-vkorg, " Sales organisation
"s_vtweg for vbak-vtweg, " Distribution channel
s_vbeln for vbak-vbeln, " Sales order number
s_usrnme for cdhdr-username, " Changed by
s_udate for cdhdr-udate. " Changed on
selection-screen: end of block b1,
begin of block b2 with frame title text-002.
parameters:
p_varint like disvariant-variant. " Display variant.
selection-screen: end of block b2.
*Initialization
initialization.
*Load display variant.
if not p_varint is initial.
move st_variant to st_tvariant.
move p_varint to st_tvariant-variant.
call function 'REUSE_ALV_VARIANT_EXISTENCE'
exporting
i_save = co_save_u
changing
cs_variant = st_tvariant.
st_variant = st_tvariant.
else.
clear st_variant.
st_variant-report = sy-repid.
endif.
at selection-screen on value-request for p_varint.
*Provide display variant list for this program.
call function 'REUSE_ALV_VARIANT_F4'
exporting
is_variant = st_variant
i_save = co_save_u
importing
e_exit = va_exit
es_variant = st_tvariant
exceptions
not_found = 2.
if sy-subrc eq 2.
message id sy-msgid type 'S'
number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
if va_exit eq space.
st_variant = st_tvariant.
p_varint = st_tvariant-variant.
endif.
endif.
*At selection screen
at selection-screen.
*Load display variant.
if not p_varint is initial.
move st_variant to st_tvariant.
move p_varint to st_tvariant-variant.
call function 'REUSE_ALV_VARIANT_EXISTENCE'
exporting
i_save = co_save_u
changing
cs_variant = st_tvariant.
st_variant = st_tvariant.
else.
clear st_variant.
st_variant-report = sy-repid.
endif.
*Start of selection
start-of-selection.
*Extract order details from VBAK
select vbeln erdat auart faksk netwr waerk vkorg vtweg vkbur fkara
kunnr xblnr
from vbak
into table it_vbak
where vkbur eq s_vkbur
" and vkorg eq s_vkorg
" and vtweg eq s_vtweg
and vbeln in s_vbeln
and trvog eq co_trvog_0.
if sy-subrc ne 0.
*No data found for selection
message s001(zgen).
exit.
endif.
loop at it_vbak into wa_vbak.
va_tabix = sy-tabix.
wa_vbak-objectid = wa_vbak-vbeln.
modify it_vbak from wa_vbak
index va_tabix
transporting objectid.
endloop.
select objectclas objectid changenr username udate utime tcode
from cdhdr
into table it_cdhdr
for all entries in it_vbak
where objectclas eq co_objectclas_verkbeleg
and objectid eq it_vbak-objectid
and username in s_usrnme
and udate in s_udate.
if sy-subrc eq 0.
select objectclas objectid changenr tabname tabkey fname chngind
value_new value_old
from cdpos
into table it_cdpos
for all entries in it_cdhdr
where objectclas eq it_cdhdr-objectclas
and objectid eq it_cdhdr-objectid
and changenr eq it_cdhdr-changenr.
endif.
select vbeln posnr fbuda
from vbkd
into table it_vbkd
for all entries in it_vbak
where vbeln eq it_vbak-vbeln
and posnr eq co_posnr_initial.
*---------------------------------------------------------------------
** Form merge_data
*---------------------------------------------------------------------
*text
----------------------------------------------------------------------
form merge_data tables pa_it_cdhdr type ty_it_cdhdr
pa_it_cdpos type ty_it_cdpos
pa_it_kna1 type ty_it_kna1
pa_it_merged type ty_it_merged
pa_it_vbak type ty_it_vbak
pa_it_vbkd type ty_it_vbkd.
*Local internal tables
data:
lit_dd03l type ty_it_dd03l,
lit_dd04t type ty_it_dd04t.
*Local work areas
data:
lwa_cdhdr type ty_cdhdr,
lwa_cdpos type ty_cdpos,
lwa_dd03l type ty_dd03l,
lwa_dd04t type ty_dd04t,
lwa_kna1 type ty_kna1,
lwa_merged type ty_merged,
lwa_vbak type ty_vbak,
lwa_vbkd type ty_vbkd.
*Local variables
data:
lva_dd03l_tabix like sy-tabix,
lva_dd04t_tabix like sy-tabix.
sort pa_it_cdhdr by objectid changenr.
sort pa_it_cdpos by objectid changenr tabname tabkey fname.
sort pa_it_kna1 by kunnr.
sort pa_it_vbak by vbeln.
sort pa_it_vbkd by vbeln.
loop at pa_it_vbak into lwa_vbak.
clear lwa_merged.
*Get description for field - determine date element
clear lwa_dd03l.
read table lit_dd03l into lwa_dd03l
with key tabname = lwa_cdpos-tabname
fieldname = lwa_cdpos-fname
binary search.
lva_dd03l_tabix = sy-tabix.
if sy-subrc ne 0.
select single tabname fieldname as4local as4vers rollname
from dd03l
into lwa_dd03l
where tabname eq lwa_cdpos-tabname
and fieldname eq lwa_cdpos-fname
and as4local eq co_as4local_a.
if sy-subrc eq 0.
insert lwa_dd03l into lit_dd03l
index lva_dd03l_tabix.
endif.
endif.
*If data element was found, get description
if not lwa_dd03l is initial.
clear lwa_dd04t.
read table lit_dd04t into lwa_dd04t
with key rollname = lwa_dd03l-rollname
ddlanguage = sy-langu
binary search.
lva_dd04t_tabix = sy-tabix.
if sy-subrc ne 0.
select single rollname ddlanguage as4local as4vers scrtext_l
from dd04t
into lwa_dd04t
where rollname eq lwa_dd03l-rollname
and ddlanguage eq sy-langu.
if sy-subrc eq 0.
insert lwa_dd04t into lit_dd04t
index lva_dd04t_tabix.
else.
lwa_dd04t-scrtext_l = 'Description for field not found'.
endif.
endif.
endif.
lwa_merged-scrtext_l = lwa_dd04t-scrtext_l.
append lwa_merged to pa_it_merged.
at end of changenr.
*Only process field changes for this change document.
exit.
endat.
endloop.
at end of objectid.
*Initialise work area so we know change document for order has
*been processed.
clear lwa_merged.
*Only process change documents for this sales order.
exit.
endat.
endloop.
endloop.
endform. " merge_data
*---------------------------------------------------------------------
** Form build_field_catalog
*---------------------------------------------------------------------
*text
----------------------------------------------------------------------
form build_field_catalog tables pa_it_fieldcat type slis_t_fieldcat_alv.
data:
*Local variable
lva_col_pos type slis_fieldcat_alv-col_pos,
*Local structure
st_fieldcat type slis_fieldcat_alv.
*---------------------------------------------------------------------
** Form output_report
*---------------------------------------------------------------------
*text
----------------------------------------------------------------------
form output_report tables pa_it_fieldcat type slis_t_fieldcat_alv
pa_it_merged type ty_it_merged.
*Local variables
data:
lva_formname type slis_formname,
lva_repid like sy-repid.
*---------------------------------------------------------------------
** Form alv_user_command
*---------------------------------------------------------------------
*text
----------------------------------------------------------------------
form alv_user_command using pa_ucomm like sy-ucomm
pa_selfield type slis_selfield.
*Local work areas
data:
lwa_merged type ty_merged.
clear lwa_merged.
read table it_merged into lwa_merged
index pa_selfield-tabindex.
case pa_selfield-fieldname.
when 'VBELN'.
*Sales order number
set parameter id 'AUN' field lwa_merged-vbeln.
call transaction 'VA03' and skip first screen.
when 'KUNNR'.
*Customer number
set parameter id 'KUN' field lwa_merged-kunnr.
set parameter id 'VKO' field space.
set parameter id 'VTW' field space.
set parameter id 'SPA' field space.
call transaction 'XD03' and skip first screen.
endcase.
endform. " alv_user_command
*---------------------------------------------------------------------
** Form read_text
*---------------------------------------------------------------------
*text
----------------------------------------------------------------------
form read_text using pa_id
pa_inline_count
pa_name
pa_object
pa_text.
*Local internal tables
data:
lit_inlines type ty_it_lines,
lit_lines type ty_it_lines.
*Local work areas
data:
lwa_lines type ty_lines.
*Local variables
data:
lva_tdname like thead-tdname.
refresh: lit_inlines,
lit_lines.
lva_tdname = pa_name.
call function 'READ_TEXT_INLINE'
exporting
id = pa_id
inline_count = pa_inline_count
language = sy-langu
name = lva_tdname
object = pa_object
tables
inlines = lit_inlines
lines = lit_lines
exceptions
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
others = 7.
loop at lit_lines into lwa_lines.
concatenate pa_text
lwa_lines-tdline
into pa_text separated by space.
endloop.
endform. " read_text ENDLOOP.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.