Вы находитесь на странице: 1из 113

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

*& module pool zvquemtl *


*----------------------------------------------------------------------*
* order screening - queue management.
************************************************************************
*$1 |11/03/2003|r barsdorf | ur-sst-03-00005
* | | | $1d) add coding for new subtotal zzwi05
* | | | (old = kzwi1)
************************************************************************
*$2 |22/07/2004|m.e. grund | ur-hba-04-00019: zque cp not to be shown
* | | |
************************************************************************
*$3 |19/02/2005|j.j.j.holmes|changes in september 2003 for sales order
* | | |addresses completely broke plant and
* | | |vendor details for purchase requisitions
* | | |so restored original code for purchase
* | | |requisitions. the sales order code was
* | | |not flagged. it is now flagged as $3
* | | |because the code restored here is
* | | |standard from the usa version
* | | |munk-69rsn9
************************************************************************
*$4 |18/07/2005|j.j.j.holmes|upgrade from danny chen for 3rd party
* | | |shipping.
* | | |relevant to ur-fbo-05-00011
************************************************************************
*$5 |22/07/2005|j.j.j.holmes|call the genosys production fm if the
* | | |header status is set to released.
************************************************************************
*$6 |29/07/2005|j.j.j.holmes|for certain item categories (table
* | | |zgenpstyvheadblk) release the pr from
* | | |sosblock if the sales order is now
* | | |fully released. for these products the
* | | |pr stays blocked if there is header level
* | | |screening.
************************************************************************
*$7 |11/08/2005|j.j.j.holmes|ur-hba-05-00004 add eban-fixkz to the
* | | |main screen.
************************************************************************
*$8 |11/08/2005|j.j.j.holmes|ur-hba-04-00011 add eban-fixkz to the
* | | |main screen.
************************************************************************
*$9 |18/10/2005|j.j.j.holmes|new check for sales order stock
* | | |look at schedule line item category
************************************************************************
*$10 |17/11/2005|j.j.j.holmes|pedr-6j8dx3. in screening items for
* | | |purchase requisitions, reasons sosblock
* | | |zcland must equal the country of the
* | | |plant
************************************************************************
*$11 |23/11/2005|j.j.j.holmes|jlag-6j7m3c. for purchase requisitions
* | | |the check to see if user has (zvs48)
* | | |authorization to release the pr
* | | |screening item has been corrupted and
* | | |anyone who can lock the pr can release
* | | |the screening item - which is very bad!
************************************************************************
*$12 |01/02/2006|a.g. mackie | with new range for delivery
* | | |numbers, the switch based on document
* | | |number did not work. so disabled code
* | | |that called vl02
************************************************************************
*$13 |03/02/2006|j.j.j.holmes|genosys project
* | | |change the name of the fm called to
* | | |send the genosys production idoc
************************************************************************
*$14 |09/03/2006|a.j.ashby |ur-hba-06-00004
* | | |select partner for doc header only
************************************************************************
*$15 |22/03/2006|a.j.ashby |ur-hba-05-00010
* | | |extend matnr field in detail screen 300
* | | |to be 18 characters. also make truncated
* | | |text fields scrolable.
************************************************************************
*$16 |03/05/2007|dsekhar |cd 5001358
* | | |151-right e-mail address in zque
************************************************************************
program zqueue message-id zi.
tables: zvs13,zvs06,vbap,vbak,kna1,zvs14t,mara,makt,likp,zvs50,vbep,
zvs48, jest, jcds, zvs07,vbcom,vbpa ,sadr,zvs02t,zvs01t,*vbapd,
zvs20,zvs12, zvs17, knvk, zccdatam, zccdatad,zliteral, lfa1,
zcrd_info, zcrd_retn, vbkd, tcurf, vbuk, t001w, eban, adr6.

tables: tvep,adrc. "$4

*----------------------------------------------------------------------*
* internal tables.
*----------------------------------------------------------------------*
*ata: ksadr like sadr occurs 0 with header line.
data: ksadr type sadr.
data: vbpa1 like vbpa occurs 10 with header line.
data: t_vbpa like vbpa occurs 10 with header line.
data: *zvs50 like zvs50 occurs 0 with header line.
data: *zvs1 like zvs13 occurs 0 with header line.

data: begin of ktab occurs 0.


include structure kna1.
data: end of ktab .

data: begin of ktab1 occurs 0.


include structure kna1.
data: end of ktab1.

data: begin of xsadrx occurs 0.


include structure sadr.
data: end of xsadrx.

data: begin of xknvk occurs 0.


include structure knvk.
data: end of xknvk.

data: begin of ktab2 occurs 0.


include structure kna1.
data: end of ktab2.

data: begin of itvtab occurs 0.


include structure zvs13.
data: end of itvtab.

data: begin of *jest occurs 0.


include structure jest.
data: end of *jest.

data: begin of *jcds occurs 0.


include structure jcds.
data: end of *jcds.

data: begin of fields occurs 0.


include structure sval.
data: end of fields.

data: begin of int_zvs13 occurs 100.


include structure zvs13.
data: kwmeng like vbap-kwmeng.
data: netpr like vbap-netpr.
data: maktx like makt-maktx.
data: bmeng(1) type c.
data: zlicdes like zvs02t-zlicdes.
data: zcomdes like zvs01t-zcomdes.
data: checkbox(1) type c.
data: end of int_zvs13.
data: bmeng(1) type c.
data: begin of int_zvs48 occurs 100.
include structure zvs48.
data: end of int_zvs48.

data begin of int_release occurs 100.


include structure zvs13.
data: kwmeng like vbap-kwmeng.
data: netpr like vbap-netpr.
data: maktx like makt-maktx.
data: bmeng(1) type c.
data: zlicdes like zvs02t-zlicdes.
data: zcomdes like zvs01t-zcomdes.
data: checkbox(1) type c.
data: end of int_release.

data: int_del like int_zvs13 occurs 0 with header line.


data: key like zvs13 occurs 0 with header line.

data: begin of chk_tab occurs 0.


include structure zvs13.
data: chekbox(1) type c.
data: end of chk_tab.

data: begin of chk_tab1 occurs 0.


include structure zvs13.
data: chekbox(1) type c.
data: end of chk_tab1.

data: begin of chk_tab2 occurs 0.


include structure zvs13.
data: chekbox(1) type c.
data: end of chk_tab2.
data: begin of itvbap occurs 0.
include structure vbap.
data: end of itvbap.

data: begin of dtab occurs 0.


include structure itab.
data: end of dtab.

data: begin of ck_tab occurs 0.


include structure zvs13.
data: checkbox(1) type c.
data: end of ck_tab.

data: begin of ck_tab2 occurs 0.


include structure int_zvs13.
data: end of ck_tab2.

data: begin of citab occurs 1.


include structure zvs13.
data: checkbox(1) type c.
data: end of citab.

data: begin of sitab occurs 1.


include structure zvs13.
data: sol_col(1) type c.
data: end of sitab.

data: begin of stvtab occurs 0.


include structure jstat.
data: end of stvtab.

data: begin of item_zvs13 occurs 0.


include structure zvs13.
data end of item_zvs13.

data: begin of int_ship occurs 0.


include structure zvs13.
data: end of int_ship.

* internal table for zccdatam.

data: begin of t_zccdatam occurs 0.


include structure zccdatam.
data: end of t_zccdatam.

* internal table for zccdatad.

data: begin of t_zccdatad occurs 0.


include structure zccdatad.
data: end of t_zccdatad.

* internal table for vbap.

data: begin of t_vbap occurs 0.


include structure vbap.
data: end of t_vbap.
* internal table for jcds.

data: begin of t_jcds occurs 0.


include structure jcds.
data: end of t_jcds.

data: begin of x_jcds occurs 0.


include structure jcds.
data: end of x_jcds.

* internal table to store conditions

data : begin of ctab occurs 0,


src(80), " condition
end of ctab.

data: begin of t_tvep occurs 0. "$9


data: ettyp type ettyp. "$9
data: pstyp type pstyp. "$9
data: knttp type knttp. "$9
data: end of t_tvep. "$9

*--------------------- end of internal tables--------------------------*


*eject
*----------------------------------------------------------------------*
* declarations *
*----------------------------------------------------------------------*
data : ws_complete(1). " complete flag.

data: has_security(1).
data: retuencode(1) type c.
data: dd03d-fieldname(1) type c value 'x'.
data: rf02d-kunnr(10) type c.
data: debi-auswl(6) type c.
data: rf02d-d0110(1) type c.
data: rf02d-d0324(1) type c.
data: doc_type(9).
data: sold_to(7).
data: ship_to(22).
data: name1 like kna1-name1.
data: name2 like kna1-name2.
data: name3 like kna1-name3.
data: name4 like kna1-name4.
data: stras like kna1-stras.
data: ort01 like kna1-ort01.
data: regio like kna1-regio.
data: land like kna1-land1.
data: pstlz like kna1-pstlz.
data: telf1 like kna1-telf1.
data: telfx like kna1-telfx.
data: smtp_addr like adr6-smtp_addr.
data: ws_smtp_addr like adr6-smtp_addr.
data: stonr(5) type c.
data: dk(1) type c.
data line1 like sy-tabix.
data line2 like sy-tabix.
data: index like sy-index.
data: selline like sy-stepl.
data security(10) type c.

data: ws_wrkdt like sy-datum,


ws_wrkdys type i,
ws_value like vbap-netwr,
ws_vbapl type i,
ws_vbeln(10),
ws_posnr like vbep-posnr,
ws_field1(80),
ws_field2(60),
ch_index(4),
ws_field(28).

*data ws_process_mode(4) value 'disp'.


controls: sigma type tableview using screen 200.
data fixed_cols like sigma-fixed_cols.
data: update_item_status(1) type c.
data: update_header_status(1) type c.
data: lines like sy-index.
data: next_line like sy-index.
data: row-num like sy-index.
data: num1 like sy-index.
data: numr like sy-index.
data: top_line type i.
data tabix like sigma-current_line.
data: checkbox(1) type c.
data: header_objnr like vbak-objnr.
data: object_number like vbak-objnr.
data: change_number like jest-chgnr.
data: ws_free(1).

data: num like sy-index.


data: fld_name(25) type c.
data: lin_no like sy-tabix.
data: linno type i.
data: total(9) type c.
data: total1(9) type c.
data: text(40) type c.
data: text1(40) type c.
data: line type i.
data: currpg like sy-pagct.
data: max_lines_pp like sy-tabix.
data: actual_row like sy-tabix.
data: pg_cnt like sy-pagct.
data: temp_lines like sy-tabix.
data: num_com_lines like sy-tabix.
data: ind like sy-tabix.
data: base like sy-loopc.
data: bas type i.
data: ext_date like zvs13-erdat.
data: until_date like sy-datum.
data: until_time like sy-uzeit.
*----------------for sorting the columns ------------------------------*
constants: markiert(1) type c value 'm'.
field-symbols: <xmark>.
data: popup_title(35).
data: count like sy-tabix.
data: ok_code100 like sy-ucomm .
data: ok_code200 like sy-ucomm.
data: ok_code300 like sy-ucomm.
data: ok_code400 like sy-ucomm.
data: ok_code1 like sy-ucomm.
data: rel_code like sy-ucomm.
data: field(100) type c.
data: field1(80) type c.
data: ccode like sy-ucomm.
data: rcode(2) type c.
data: fcode(2) type c.
data: ccode1 like sy-ucomm.
data: line_selector type c.
data: compliance_description like zvs14t-zcrdes.
data: product-description like makt-maktx .
data: comp_type_description like zvs01t-zcomdes.
data: license-description like zvs02t-zlicdes.
data: quantity like vbap-zmeng.
data: w_zcomtyp like zvs13-zcomtyp.
data: w_sales_org like zvs13-vkorg. "$7
data: w_zlictyp like zvs13-zlictyp.
data: w_stonr like zvs13-stonr.
data: w_zqueid like zvs13-zqueid.
data: w_erdat like zvs13-erdat.
data: w_erdat1 like vbcom-audat_bis.
data: w_vbeln like zvs13-vbeln.
data: w_kunnr like zvs13-kunnr.
data: w_vsbed like zvs13-vsbed.
data: plant like zvs13-zshipno.
data: w_route like zvs13-route.
data: w_land1 like zvs13-land1.
data: w_zcland like zvs13-zcland.
data: w_zohind like zvs13-zohind.
data: w_regio like zvs13-regio.
data: w_delivering_plant like vbap-werks.
data: w_ordering_method like vbkd-bsark.
data: include_delayed(1).
data: exclude_delayed(1).
data: only_delayed(1).
data: sol_col(1) type c,
line_count type i.
data top_line_item type i.
data: button1 value 'x'.
data: button2 value space.
data: button3 value space.
data: looplines like sy-loopc.
data: newest(1) type c.
data: oldest(1) type c.
data: counter type i.
data: itab4 like itab occurs 10 with header line.
types: begin of zcxta_column,
screen like screen,

index type i,
selected,
vislength like icon-oleng,
invisable,
end of zcxta_column,
begin of zcxta_control,
fixed_cols type i,
lines type i,
top_line type i,
current_line type i,
left_col type i,
line_sel_mode type i,
col_sel_mode type i,
line_selector,
v_scroll,
h_grid,
v_grid,
cols type zcxta_column occurs 10,
end of zcxta_control.
data: input_entry.
data: wa type zcxta_column.
data: field-name like screen-name.
data: six type i value 6.

data: begin of itab occurs 1.


include structure zvs13.
data: name1 like kna1-name1. "jjjh/dc 04/02/2003
data: bsark like vbkd-bsark.
data: werks like vbap-werks.
data: kdgrp like vbkd-kdgrp.
data: bstkd like vbkd-bstkd. "jjjh/dc 04/02/2003
data: lifsp like vbep-lifsp.
data: chekbox(1) type c.
data: fixkz like eban-fixkz. "$8

data: end of itab.

data: begin of itab10 occurs 1.


* include structure zvs13.
data: vbeln like zvs13-vbeln.
data: end of itab10.

data: begin of indu occurs 1.


include structure zvs13.
data: end of indu.

data: begin of seenu occurs 0.


include structure vbak.
data: end of seenu.

data: begin of seenu1 occurs 0.


include structure likp.
data: end of seenu1.

data: begin of i_tab occurs 100.


include structure zvs06.
data: posnr like zvs13-posnr.
data: zcomrea like zvs13-zcomrea.
data: matnr like mara-matnr.

data: end of i_tab.

data: begin of i_tab1 occurs 100.


include structure zvs06.
data: end of i_tab1.

* define internal table to store bdc data

data: begin of t_bdc occurs 0.


include structure bdcdata. " bdc structure
data: end of t_bdc.

* define internal table to store message.

data: begin of t_message occurs 0.


include structure bdcmsgcoll.
data: end of t_message.

data: wx_vbeln like vbak-vbeln,


wx_callact(4).

data: begin of xvbep occurs 10. "$4


include structure vbep. "$4
data: end of xvbep. "$4

data: ws_check_third_party(1). "$4

data: all_third_party_item_released(1). "$4

data: begin of t_zgenpstyvheadblk occurs 0. "$6


data: pstyv type pstyv. "$6
data: end of t_zgenpstyvheadblk. "$6

data: popup_text1(35).
data: popup_text2(35).
data: int_adr6 like adsmtp occurs 0 with header line. "$16
*data: w_prsnr like knvk-prsnr.
data: t_vbpa10 like vbpa occurs 10 with header line.
data: it_tab3 like adrc occurs 10 with header line.
data: t_vbpa2 like vbpa occurs 10 with header line.
data: t_knvk like knvk occurs 10 with header line.
data: t_adr6 like adr6 occurs 10 with header line.
data: t_adr61 like adr6 occurs 10 with header line.
data: t_vbpa4 like vbpa occurs 10 with header line.
data: it_vbpa002 like vbpa occurs 10 with header line.
data : begin of it_adr6 occurs 0,
smtp_addr like adr6-smtp_addr,
addrnumber like adr6-addrnumber,
end of it_adr6. "$16

tables: zvs24t.

constants: c_purchase_requisition_low type vbeln value '0000000001'.


constants: c_purchase_requisition_high type vbeln value '0009999999'.
constants: c_delivery_low type vbeln value '0040000000'.
************************************************************************
*&---------------------------------------------------------------------*
*& module status_0100 output
*&---------------------------------------------------------------------*
module status_0100 output.
set pf-status 'zsdf'.
set titlebar 'zsd1'.
* get parameter id 'aun' field zvs13-vbeln. $2

if sy-ucomm = 'back' or sy-ucomm = 'cont'.


clear zvs13.
clear oldest.
clear newest.
clear vbap-werks. " delivery plant
clear vbkd-bsark. " ordering method
endif.
if sy-ucomm = 'canc'.
clear zvs13.
clear oldest.
clear newest.
clear vbap-werks. " delivery plant
clear vbkd-bsark. " ordering method
endif.
if sy-ucomm = 'no'.
clear zvs13-vbeln.
endif.
endmodule. " status_0100 output
*&---------------------------------------------------------------------*
*& module user_command_0100 input
*&---------------------------------------------------------------------*
module user_command_0100 input.
case ok_code100.

* when 'ente'.
* set screen 100.
* move ok_code100 to ok_code1.
when 'exec' or 'ente'.
clear ok_code1.
perform check_stonr.
perform selection_of_table_zvs13.

loop at *zvs50.
delete itab where vbeln = *zvs50-vbeln.
endloop.

sigma-line_sel_mode = 2.
describe table itab lines sigma-lines.

if oldest = 'x'.
sort itab by erdat.
elseif newest = 'x'.
sort itab descending.
endif.
clear ok_code100.
when 'canc'.
clear ok_code100.
set screen 0.
leave screen.

when 'exit'.
clear ok_code100.
set screen 0.
leave screen.
when 'back'.
clear ok_code100.
set screen 0.
leave screen.

endcase.
endmodule. " user_command_0100 input

*&---------------------------------------------------------------------*
*& module user_command_0200 input
*&---------------------------------------------------------------------*
module user_command_0200 input.
case ok_code200.
*----------------------------------------------------------------------*
* this if for popbox which shows the total no of orders and records.
*----------------------------------------------------------------------*
when 'orde'.
clear total.
clear total1.
refresh itab10.
describe table itab lines lin_no.
move lin_no to total .
loop at itab.
describe table itab lines lin_no.
read table itab .
move itab-vbeln to itab10-vbeln.
append itab10.
endloop.
sort itab10 by vbeln.
delete adjacent duplicates from itab10.
describe table itab10 lines lin_no.
move lin_no to total1.
concatenate 'total no of records =' total into text
separated by ' '.
concatenate 'total no of orders =' total1 into text1
separated by ' '.

call function 'popup_to_display_text'


exporting
titel = 'order screening - queue management'
textline1 = text
textline2 = text1
exceptions
others = 1.

clear ok_code200.
if sy-ucomm = 'yes'.
clear ok_code200.
set screen 200. leave screen.
endif.
when 'canc' or 'f12'.
clear ok_code200.
set screen 100.
leave screen.

when 'exit'.
clear ok_code200.
set screen 0.
leave screen.

when 'more'.
refresh chk_tab.
refresh chk_tab1.
refresh *zvs50.
clear *zvs50.
loop at itab.
if itab-chekbox = 'x'.
move itab-vbeln to chk_tab-vbeln.
move 'x' to chk_tab-chekbox.
append chk_tab.
endif.
endloop.
sort chk_tab by vbeln.
delete adjacent duplicates from chk_tab.

loop at chk_tab.
select single * from zvs50 where vbeln = chk_tab-vbeln.
if sy-subrc = 0.
move 'order screening - queue management' to popup_title.
concatenate 'sales document' chk_tab-vbeln
'is being processed by' zvs50-ernam into field separated by ' '.

concatenate 'on date' zvs50-erdat 'at time' zvs50-uzeit


into field1 separated by ' '.
call function 'popup_to_inform'
exporting
titel = popup_title
txt1 = field
txt2 = field1
exceptions
others = 1.

else.
move-corresponding chk_tab to *zvs50.
move sy-uname to *zvs50-ernam.
move sy-datum to *zvs50-erdat.
move sy-uzeit to *zvs50-uzeit.
append *zvs50.
insert into zvs50 values *zvs50.
num1 = 1.
read table chk_tab index num1.
endif.
endloop.
if sy-ucomm = 'yes'.
clear ok_code200.
set screen 200. leave screen.
endif.
if chk_tab-chekbox <> 'x'.
refresh chk_tab1.
get cursor line selline.
loop at itab.
move-corresponding itab to chk_tab1.
append chk_tab1.
endloop.
tabix = sigma-top_line + selline - 1.
read table chk_tab1 index tabix.
if sy-subrc ne 0.
clear ok_code200.
set screen 200. leave screen.
endif.
modify chk_tab1 index tabix.
select single * from zvs50 where vbeln = chk_tab1-vbeln.
if sy-subrc = 0.
move 'order screening - queue management' to popup_title.
concatenate 'sales document' chk_tab1-vbeln
'is being processed by' zvs50-ernam into field separated by ' '.
concatenate 'on date' zvs50-erdat 'at time' zvs50-uzeit
into field1 separated by ' '.
call function 'popup_to_inform'
exporting
titel = popup_title
txt1 = field
txt2 = field1
exceptions
others = 1.
else.
perform read_table_chk_tab1.
top_line = 1.
endif.
if sy-ucomm = 'yes'.
clear ok_code200.
set screen 200. leave screen.
endif.
endif.
clear ok_code200.
set screen 300.
leave screen.

when 'back' or 'f3' .


move ok_code200 to ccode1.
clear ok_code200.
set screen 100.
leave screen.

when 'asce'.
perform ascending_columns_selected.

when 'desc'.
perform descending_columns_selected.

when 'sele'.
perform select.

when 'dese'.
perform deselect.
clear ok_code200.

when 'frst'.
clear ok_code200.
perform paging_200 using 'frst'.
clear ok_code200.

when 'prev'.
perform paging_200 using 'prev'.
clear ok_code200.

when 'next'.
clear ok_code200.
perform paging_200 using 'next'.

when 'last'.
perform paging_200 using 'last'.
clear ok_code200.
endcase.
endmodule. " user_command_0200 input
*&---------------------------------------------------------------------*
*& module status_0200 output
*&---------------------------------------------------------------------*
module status_0200 output.
set pf-status 'zsdg'.
set titlebar '200'.
endmodule. " status_0200 output
*&---------------------------------------------------------------------*
*& module display_sigma output
*&---------------------------------------------------------------------*
module display_sigma output.
if sy-ucomm = 'back' or
sy-ucomm = 'canc' or
sy-ucomm = 'neor'.
loop at int_del.
delete itab where vbeln = int_del-vbeln
and posnr = int_del-posnr
and zcomrea = int_del-zcomrea
and zqueid = int_del-zqueid
and zcland = int_del-zcland
and zcomgrp = int_del-zcomgrp.
endloop.
endif.
if sy-ucomm = 'rlse'.
*----------------------------------------------------------------------*
* when the order is being released then if it comes back to summary scre
*-----------------------------------------------------------------------
loop at ck_tab.
delete itab
where vbeln = ck_tab-vbeln and posnr = ck_tab-posnr
and zcomrea = ck_tab-zcomrea
and zqueid = ck_tab-zqueid
and zcland = ck_tab-zcland
and zcomgrp = ck_tab-zcomgrp.
endloop.
endif.

if sy-ucomm = 'furt'.
*----------------------------------------------------------------------*
* this is for delay the function code used is furt
* when the order is delayed it should not be seen on summary screen.
*----------------------------------------------------------------------*
if exclude_delayed = 'x'.
* if ck_tab-zohdat > sy-datum or
* ck_tab-zohtim > sy-uzeit.
loop at ck_tab.
delete itab
where vbeln = ck_tab-vbeln and posnr = ck_tab-posnr
and zcomrea = ck_tab-zcomrea
and zqueid = ck_tab-zqueid.
endloop.
* endif.
endif.
endif.
loop at screen.
if screen-name <> 'sol_col'.
screen-input = 0.
endif.
modify screen.
endloop.
if itab-vbeln <> ' '.
move sitab-sol_col to sol_col.
endif.
* sigma-top_line = 1.
zvs13-zcland = itab-zcland.
zvs13-zcomtyp = itab-zcomtyp.
zvs13-zlictyp = itab-zlictyp.
zvs13-matnr = itab-matnr.
zvs13-zcomrea = itab-zcomrea.
zvs13-vsbed = itab-vsbed.
zvs13-route = itab-route.
zvs13-vbeln = itab-vbeln.
zvs13-posnr = itab-posnr.
zvs13-kunnr = itab-kunnr.
zvs13-land1 = itab-land1.
zvs13-regio = itab-regio.
zvs13-erdat = itab-erdat.
zvs13-zqueid = itab-zqueid.
zvs13-zohdat = itab-zohdat.
sol_col = itab-chekbox.
* select name1 from kna1 into itab-ame1 "jjjh/dc 04/02/2003
* where kunnr = zvs13-kunnr. "jjjh/dc 04/02/2003
kna1-name1 = itab-name1. "jjjh/dc 04/02/2003
* endselect. "jjjh/dc 04/02/2003
* select single bsark kdgrp from vbkd into (itab-bsark, itab-kdgrp)
* "jjjh/dc 04/02/2003
* where vbeln = itab-vbeln "jjjh/dc 04/02/2003
* and posnr = 000000. "jjjh/dc 04/02/2003
vbkd-bsark = itab-bsark.
vbkd-kdgrp = itab-kdgrp.
vbkd-bstkd = itab-bstkd.
* select single werks from vbap into itab-werks
* where vbeln = itab-vbeln
* and posnr = itab-posnr.
vbap-werks = itab-werks.
* select single lifsp from vbep into itab-lifsp "jjjh/dc 04/02/2003
* where vbeln = itab-vbeln "jjjh/dc 04/02/2003
* and posnr = itab-posnr. "jjjh/dc 04/02/2003
vbep-lifsp = itab-lifsp.
eban-fixkz = itab-fixkz. "$8

endmodule. " display_sigma output


*eject
*&---------------------------------------------------------------------*
*& module check_document input
*&---------------------------------------------------------------------*
module check_document input.

endmodule. " check_document input


*eject
*&---------------------------------------------------------------------*
*& module check_stonr input
*&---------------------------------------------------------------------*
form check_stonr.
fields zvs13-zcomtyp.
move zvs13-zcomtyp to w_zcomtyp.

fields zvs13-zlictyp.
move zvs13-zlictyp to w_zlictyp.

if button1 <> space.


move 'x' to exclude_delayed.
clear include_delayed.
clear only_delayed.

elseif button2 ne space.


move 'x' to include_delayed.
clear only_delayed.
clear exclude_delayed.
else.
move 'x' to only_delayed.
clear exclude_delayed.
clear include_delayed.
endif.

fields zvs13-vkorg. "$7


move zvs13-vkorg to w_sales_org. "$7

fields zvs13-zqueid.
move zvs13-zqueid to w_zqueid.

fields zvs13-stonr.
move zvs13-stonr to w_stonr.

fields zvs13-erdat.
move zvs13-erdat to w_erdat.

fields vbcom-audat_bis.
move vbcom-audat_bis to w_erdat1.

fields zvs13-kunnr.
move zvs13-kunnr to w_kunnr.

fields zvs13-vsbed.
move zvs13-vsbed to w_vsbed.

fields zvs13-route.
move zvs13-route to w_route.

fields zvs13-land1.
move zvs13-land1 to w_land1.

fields zvs13-zcland.
move zvs13-zcland to w_zcland.

fields zvs13-regio.
move zvs13-regio to w_regio.

fields zvs13-vbeln.
move zvs13-vbeln to w_vbeln.

fields eban-werks.
move eban-werks to plant.

fields vbap-werks.
move vbap-werks to w_delivering_plant.

fields vbkd-bsark.
move vbkd-bsark to w_ordering_method.

endform. " check_stonr input


*eject
*&---------------------------------------------------------------------*
*& module user_command_0300 input
*&---------------------------------------------------------------------*
module status_0300 output.
set pf-status 'z300'.
set titlebar '300'.

clear: ok_code300.
endmodule. " status_0300 output
*eject
*---------------------------------------------------------------------*
*& form paging
*&---------------------------------------------------------------------*
form paging using code.
data: linno type i,
i type i.
describe table int_zvs13 lines linno.
case code.
when 'frst'. top_line = 1.

when 'prev'.
top_line = top_line - line_count.
if top_line = 0.
top_line = 1.
endif.

when 'next'.
i = top_line + line_count.
linno = linno - line_count + 1.
if linno le 0.
linno = 1.
endif.
if i le linno.
top_line = i.
else.
top_line = linno.
endif.

when 'last'.
top_line = linno - line_count + 1.
if top_line le 0.
top_line = 1.
endif.
endcase.

endform. " paging


*eject
*&---------------------------------------------------------------------*
*& form direct_access
*&---------------------------------------------------------------------*
module direct_access.
if not zvs13-vbeln is initial.
if sy-ucomm = 'exec' or
sy-ucomm = 'ente'.
clear w_zqueid.
clear w_zcland.
clear indu.
refresh indu.
clear itab.
refresh itab.
select *
from zvs13
into table indu
where vbeln = zvs13-vbeln
and ( stonr <> 50 )
and ( stonr <> 40 ).
loop at indu.
endloop.
if indu-vbeln = ' ' and
zvs13-vbeln <> ' '.
perform selection_order_status.
elseif zvs13-vbeln = ' '.
exit.
else.
clear rcode.
perform selection_reveiw_screen.
endif.
if sy-ucomm = 'cont'.
set screen 100.
leave screen.
endif.
endif.
endif.
endmodule. " direct_access
*eject
*&---------------------------------------------------------------------*
*& module fill_scr_400 output
*&---------------------------------------------------------------------*
module fill_scr_400 output.
mara-matnr = ck_tab-matnr.
zvs13-posnr = i_tab-posnr.
zvs06-zcomment = i_tab-zcomment.
endmodule. " fill_scr_400 output
*eject
*---------------------------------------------------------------------*
* module select_scr_400 output *
*---------------------------------------------------------------------*
module select_scr_400 output.
refresh i_tab.
mara-matnr = ck_tab-matnr.
zvs13-posnr = ck_tab-posnr.
select single * from mara
where matnr = ck_tab-matnr.
if sy-subrc = 0.
select single * from makt
where matnr = ck_tab-matnr and
spras = 'e'.
select * from zvs06 into table i_tab1
where zcland = ck_tab-zcland and
bismt = mara-bismt.
if sy-subrc = 0.
loop at i_tab1.
move-corresponding i_tab1 to i_tab.
move ck_tab-posnr to i_tab-posnr.
move ck_tab-zcomrea to i_tab-zcomrea.
append i_tab.
endloop.
else.
move ck_tab-matnr to i_tab-bismt.
move 'no product comments exists for this material'
to i_tab-zcomment.
move ck_tab-posnr to i_tab-posnr.
move ck_tab-zcomrea to i_tab-zcomrea.
append i_tab.
endif.
else.
move ' ' to makt-maktx.
move ' ' to i_tab-bismt.
move 'no product comments exists for this material'
to i_tab-zcomment.
move ck_tab-posnr to i_tab-posnr.
move ck_tab-zcomrea to i_tab-zcomrea.
append i_tab.
endif.
top_line = 1.
endmodule. " fill_scr_400 output
*&---------------------------------------------------------------------*
*& module set_line_count input
*&---------------------------------------------------------------------*
module set_line_count input.
line_count = sy-loopc.
endmodule. " set_line_count input
*---------------------------------------------------------------------*
* module check_selection input *
*---------------------------------------------------------------------*
module check_selection input.
endmodule. " set_line_count input
*&---------------------------------------------------------------------*
*& module status_0400 output
*&---------------------------------------------------------------------*
module status_0400 output.
set pf-status 'z400'.
set titlebar '400'.
endmodule. " status_0400 output
*&---------------------------------------------------------------------*
*& module display_order_item output
*&---------------------------------------------------------------------*
module display_order_item output.
if sy-ucomm = 'disp' or
sy-ucomm = 'chan'.
move ' ' to int_zvs13-checkbox.
endif.

if exclude_delayed = 'x'.
if int_zvs13-zohdat < sy-datum or
int_zvs13-zohdat = sy-datum and int_zvs13-zohtim < sy-uzeit.
move ' ' to int_zvs13-zohdat.
move ' ' to int_zvs13-zohtim.
endif.
endif.

if include_delayed = 'x'.
if int_zvs13-zohdat < sy-datum or
int_zvs13-zohdat = sy-datum and int_zvs13-zohtim < sy-uzeit.
move ' ' to int_zvs13-zohdat.
move ' ' to int_zvs13-zohtim.
endif.
endif.
if vbak-vbeln < c_purchase_requisition_high and " purchase requisition
vbak-vbeln >= c_purchase_requisition_low.
select single * from eban
where banfn = int_zvs13-vbeln
and bnfpo = int_zvs13-posnr.
if sy-subrc = 0.
vbap-kwmeng = eban-menge.
vbap-netpr = eban-preis.
endif.
else.
select netpr from vbap into int_zvs13-netpr
where vbeln = int_zvs13-vbeln and
posnr = int_zvs13-posnr.
vbap-netpr = int_zvs13-netpr.
endselect.
select kwmeng from vbap into int_zvs13-kwmeng
where vbeln = int_zvs13-vbeln and
posnr = int_zvs13-posnr.
vbap-kwmeng = int_zvs13-kwmeng.
endselect.
select * from vbep where vbeln = int_zvs13-vbeln and
posnr = int_zvs13-posnr.
if int_zvs13-kwmeng > vbep-bmeng.
move 'x' to bmeng.
endif.
endselect.
endif.
if int_zvs13-zqueid = 'keyword'.
zvs01t-zcomdes = int_zvs13-zkeywrd.
else.
select zcomdes from zvs01t into comp_type_description
where zcomtyp = int_zvs13-zcomtyp.
zvs01t-zcomdes = comp_type_description.
endselect.
endif.
vbak-vbeln = int_zvs13-vbeln.
zvs13-matnr = int_zvs13-matnr.
zvs13-zcomtyp = int_zvs13-zcomtyp.
zvs13-zlictyp = int_zvs13-zlictyp.
zvs13-route = int_zvs13-route.
zvs13-posnr = int_zvs13-posnr.
zvs13-erdat = int_zvs13-erdat.
zvs13-zqueid = int_zvs13-zqueid.
zvs13-zohdat = int_zvs13-zohdat.
zvs13-zohtim = int_zvs13-zohtim.
zvs13-zseqno = int_zvs13-zseqno.
zvs14t-zcomrea = int_zvs13-zcomrea.
checkbox = citab-checkbox.
checkbox = int_zvs13-checkbox.

select zcrdes from zvs14t into compliance_description


where zcomrea = int_zvs13-zcomrea.
zvs14t-zcrdes = compliance_description.
endselect.
select maktx from makt into product-description
where matnr = int_zvs13-matnr.
makt-maktx = product-description.
endselect.
select zlicdes from zvs02t into license-description
where zlictyp = int_zvs13-zlictyp.
zvs02t-zlicdes = license-description.
endselect.
* select zvs01t-zcomdes from zvs01t into comp_type_description
* where zcomtyp = int_zvs13-zcomtyp.
* zvs01t-zcomdes = comp_type_description.
* endselect.
endmodule. " display_order_item output
*&---------------------------------------------------------------------*
*& module display_order_header output
*&---------------------------------------------------------------------*
module display_order_header output.
if sy-ucomm = 'chan'.
perform record_change.
endif.

if sy-ucomm = 'rlse'.
describe table chk_tab lines lin_no.
if num1 > 1.
perform furl.
endif.
endif.

if sy-ucomm = 'exec' or
sy-ucomm = 'ente'.
perform top_part_of_screen.
endif.
*----------------------------------------------------------------------*
* this is for next order, more(details),furt(delay), pushbuttons ------*
*----------------------------------------------------------------------*
if sy-ucomm = 'more' or
sy-ucomm = 'furt' or
sy-ucomm = 'neor'.
if chk_tab-chekbox = 'x'.
move chk_tab-vbeln to vbak-vbeln.
else.
if sy-ucomm = 'furt'.
else.
move chk_tab1-vbeln to vbak-vbeln .
endif.
endif.

if vbak-vbeln < c_purchase_requisition_high and "$3


"purchase requisition
vbak-vbeln >= c_purchase_requisition_low. "$3
refresh itvtab.
select *
from zvs13
into table itvtab
where vbeln = vbak-vbeln
and stonr <> 40.
loop at itvtab.
move itvtab-zshipno to vbak-kunnr.
move itvtab-kunnr to kna1-kunnr.
endloop.
else. "$3
select * "$3
into corresponding fields of table t_vbpa "$3
from vbpa "$3
where vbeln = vbak-vbeln "$3
and posnr = '000000'. "$3

loop at t_vbpa. "$3


if t_vbpa-parvw = 'ag'. "$3
move t_vbpa-kunnr to kna1-kunnr. "$3
elseif t_vbpa-parvw = 'we'. "$3
move t_vbpa-kunnr to vbak-kunnr. "$3
endif. "$3
endloop. "$3
endif. "$3

perform header.
perform bottom_screen.
endif.
endmodule. " display_order_header output
*&---------------------------------------------------------------------*
*& module get_300 input
*&---------------------------------------------------------------------*
module get_300 input.
line_count = sy-loopc.
endmodule. " get_300 input
*&---------------------------------------------------------------------*
*& module user_command_0300 input
*&---------------------------------------------------------------------*
module user_command_0300 input.
data: compliance_country like zvs20-zcland,
license_type like zvs20-zlictyp,
partner_function like vbpa-parvw,
customer_number like zvs20-kunnr.

case: ok_code300.
when 'exit'.
perform exit.
set screen 0.
leave screen.

when 'back'.
perform back.
set screen 200.
leave screen.

when 'canc'.
perform canc.
set screen 200.
leave screen.

when 'neor'.
perform neor using 'neor'.

when 'sele'.
perform mark_all.

when 'dese'.
perform delete_all_marks.
clear ok_code300.

when 'comt'.
clear fcode.
perform comment.

when 'frst'.
perform paging using 'frst'.
when 'prev'.
perform paging using 'prev'.
when 'next'.
perform paging using 'next'.
when 'last'.
perform paging using 'last'.

when 'dela'.
perform delay.
if sy-ucomm = 'cont' or
sy-ucomm = 'canc'.
perform secu_delay.
else.
perform else.
endif.
when 'disp'.
perform display.

when 'chan'.
perform change.

when 'ques'.
perform ques.

when 'ship'.
clear int_ship.
refresh int_ship.
select *
from zvs13
into table int_ship
where vbeln = vbak-vbeln
and posnr = 000000
and stonr = 30.
loop at int_ship.
endloop.
if int_ship-posnr = '000000' and
int_ship-stonr = 30.
call screen 700 starting at 11 06 ending at 50 13.
else.
select * from zvs24t
where zpopup = 'shippable'
and spras = sy-langu.
endselect.
if sy-subrc = 0.
move zvs24t-zpopdes to popup_text1.
move zvs24t-zpopdes+35(35) to popup_text2.
else.
move 'do you want to ship' to popup_text1.
move 'the remaining items ?' to popup_text2.
endif.

call function 'popup_to_confirm_step'


exporting
defaultoption = 'y'
textline1 = popup_text1
textline2 = popup_text2
titel = 'order screening - queue management'
exceptions
others = 1.
if sy-ucomm = 'yes'.
perform shippable.
perform update_jcds.
perform check_third_party_sos_block. "$4
* if all_third_party_item_released = 'x'. "$4
* perform release_third_party_sos_block. "$4
* endif. "$4
elseif sy-ucomm = 'no' or
sy-ucomm = 'canc'.
set screen 300. leave screen.
endif.
endif.

when 'rlse'.
perform check.
perform update_header_status.
if sy-ucomm = 'cont'.
loop at int_zvs13.
move ' ' to int_zvs13-checkbox.
modify int_zvs13.
move int_zvs13-checkbox to citab-checkbox.
append citab.
endloop.
set screen 300.
leave screen.
else.
* perform proc_creditcrd_new.
* perform proc_creditcrd.
perform mian.

endif.
when 'view'.
perform view_released_orders.
when 'cust'.

************************************************************************
************************************************************************
************************************************************************
************************************************************************
* authority check included by rjb as per ur-pha-03-00036
authority-check object 's_tcode'
id 'tcd' field 'xd02'.
if sy-subrc <> 0.
message w000 with
'you have no authority to change the customer master'.
perform customer_transaction_xd03.
clear ok_code300.
else.
************************************************************************
************************************************************************
************************************************************************
************************************************************************
perform customer_transaction_xd02.
clear ok_code300.
endif.
when 'zv20'.
perform link_to_threshold_viewing.
when 'zreg'.
perform link_to_license_set_up.
endcase.
endmodule. " user_command_0300 input
*&---------------------------------------------------------------------*
*& module user_command_0400 input
*&---------------------------------------------------------------------*
module user_command_0400 input.
case ok_code400.
when 'back'.
if fcode = ' '.
perform scr_400_back.
else.
perform release_scr_400_back.
endif.
when 'exit'.
if fcode = ' '.
perform scr_400_exit.
else.
perform release_scr_400_back.
endif.

when 'canc'.
if fcode = ' '.
set screen 300.
leave screen.
else.
set screen 800.
leave screen.
endif.
when 'next'.
if fcode = ' '.
perform next using 'next'.
else.
perform released_order_next using 'next'.
endif.
endcase.
endmodule. " user_command_0400 input
*&---------------------------------------------------------------------*
*& form mark_all
*&---------------------------------------------------------------------*
* checkboxes selection
*----------------------------------------------------------------------*
form mark_all.
refresh citab.
loop at int_zvs13.
move 'x' to int_zvs13-checkbox.
modify int_zvs13.
move int_zvs13-checkbox to citab-checkbox.
append citab.
endloop.
endform. " mark_all
*&---------------------------------------------------------------------*
*& form delete_all_marks
*&---------------------------------------------------------------------*
* delesecting the checkboxes
*&---------------------------------------------------------------------*
form delete_all_marks.
loop at int_zvs13.
move ' ' to int_zvs13-checkbox.
modify int_zvs13.
move int_zvs13-checkbox to citab-checkbox.
append citab.
endloop.
endform. " delete_all_marks
*&---------------------------------------------------------------------*
*& form select
*&---------------------------------------------------------------------*
form select.
refresh sitab.
loop at itab.
move 'x' to itab-chekbox. "sol_col.
modify itab.
move itab-chekbox to sitab-sol_col.
append sitab.
endloop.
endform. " select
*&---------------------------------------------------------------------*
*& form deselect
*&---------------------------------------------------------------------*
form deselect.

loop at itab.
move ' ' to itab-chekbox. "sol_col.
modify itab.
move itab-chekbox to sitab-sol_col.
append sitab.
endloop.
endform. " deselect
*&---------------------------------------------------------------------*
*& form get_page_count
*&---------------------------------------------------------------------*
include zvuaquem.
*&---------------------------------------------------------------------*
*& module check_stonr input
*&---------------------------------------------------------------------*
module check_stonr input.
if zvs13-stonr = itab-stonr.
endif.
endmodule. " check_stonr input
*&---------------------------------------------------------------------*
*& form next
*&---------------------------------------------------------------------*
form next using ccode.
describe table ck_tab lines lin_no.

* case ccode.
* describe table ck_tab lines lin_no.
if numr < lin_no.
numr = numr + 1.
if numr > 1.
endif.
read table ck_tab index numr.
else.
loop at int_zvs13.
move ' ' to int_zvs13-checkbox.
modify int_zvs13.
move int_zvs13-checkbox to citab-checkbox.
append citab.
endloop.
set screen 300. leave screen.
endif.
* endcase.
endform. " next
*&---------------------------------------------------------------------*
*& module modify_itab input
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
module modify_itab input.
ind = sigma-current_line + sy-stepl - 1.
modify itab index ind.
endmodule. " modify_itab input
*&---------------------------------------------------------------------*
*& module set_line_count output
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
module set_line_count output.
* base = sy-loopc + 1.
endmodule. " set_line_count output
*&---------------------------------------------------------------------*
*& module proc-marked input
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
module proc-marked input.
if sy-ucomm = 'back'.
clear sitab.
endif.
clear chk_tab.
clear chk_tab1.
bas = sy-loopc + 1.
num = bas - sy-loopc + sigma-top_line - 1.
read table itab index num.
if sol_col = 'x'.
move 'x' to itab-chekbox.
modify itab index num.
else.
move ' ' to itab-chekbox.
modify itab index num.
endif.
endmodule. " proc-marked input
*&---------------------------------------------------------------------*
*& module proc-marked1 input
*&---------------------------------------------------------------------*
* *
*----------------------------------------------------------------------*
module proc-marked1 input.
clear ck_tab.
bas = sy-loopc + 1.
describe table int_zvs13 lines linno.
num = bas - sy-loopc + top_line - 1.
if checkbox = 'x'.
move 'x' to int_zvs13-checkbox.
modify int_zvs13 index num.
else.
move ' ' to int_zvs13-checkbox.
modify int_zvs13 index num.
endif.
endmodule. " proc-marked1 input
*eject
*&---------------------------------------------------------------------*
*& form check
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
* checking of user profile to release and updating of table zvs13 when
* the order is being released
*----------------------------------------------------------------------*
form check.
refresh ck_tab.
loop at int_zvs13.
if int_zvs13-checkbox = 'x'.
move 'n' to has_security.
select single * from zvs48
where zcland = int_zvs13-zcland and
uname = sy-uname and
zqueid = int_zvs13-zqueid.
if sy-subrc <> 0.
select * from zvs48 into table int_zvs48
where uname = sy-uname and
zqueid = int_zvs13-zqueid.
if sy-subrc = 0.
loop at int_zvs48.
select single * from zvs07
where zctygrp = int_zvs48-zcomgrp and
zland = int_zvs13-zcland.
if sy-subrc = 0.
move 'y' to has_security.
endif.
endloop.
endif.
else.
move 'y' to has_security.
endif.

if has_security = 'y'. "$11


if vbak-vbeln < c_purchase_requisition_high and
vbak-vbeln >= c_purchase_requisition_low.
" purchase requisition
perform lock_purchase_requisition.
endif.
endif. "$11

if has_security = 'y'.

* this only does something if document is a purchase requisition

perform check_sales_order_stock.
if lin_no > 0.
move ' ' to int_zvs13-checkbox.
modify int_zvs13.
continue.
endif.
move-corresponding int_zvs13 to ck_tab.
append ck_tab.
else.
call screen 500 starting at 11 06 ending at 50 13.
endif.
endif.
endloop.
loop at ck_tab.
* "purchase requisition
if ck_tab-vbeln < c_purchase_requisition_high and
ck_tab-vbeln >= c_purchase_requisition_low.
perform requisition_strategy_release
using ck_tab-vbeln ck_tab-posnr.
if sy-subrc <> 0. " strategy not released
continue. " do not update zvs13
endif.
endif.

if ck_tab-stonr = 20 or
ck_tab-stonr = 30 or
ck_tab-stonr = 50.
update zvs13 set stonr = 40
name1_gp = sy-uname
zabdat = sy-datum
aenam = sy-uname
laeda = sy-datum
lauhr = sy-uzeit
zabtim = sy-uzeit
where zcland = ck_tab-zcland and
zcomrea = ck_tab-zcomrea and
zcomgrp = ck_tab-zcomgrp and
vbeln = ck_tab-vbeln and
zseqno = ck_tab-zseqno and
posnr = ck_tab-posnr and
zcomtyp = ck_tab-zcomtyp and
zlictyp = ck_tab-zlictyp.
if sy-subrc = 0.
perform check_line_item_comp_reasons.
endif.
endif.
endloop.
endform. "check
*eject
*---------------------------------------------------------------------*
* form check_sales_order_stock *
*---------------------------------------------------------------------*
form check_sales_order_stock.
tables: ebkn.

* this routine only operates on purchase requisitions not sales orders

data: ws_objnr_tab "$4


type standard table of jsto_pre with header line, "$4
ws_status_tab "$4
type standard table of jest with header line, "$4
ws_wbna_status(1). "$4

clear lin_no.

if vbak-vbeln < c_purchase_requisition_high and


vbak-vbeln >= c_purchase_requisition_low. " purchase requisition
else.
exit.
endif.

check int_zvs13-zqueid = 'sosblock'. "$4

select single *
from eban
where banfn = int_zvs13-vbeln
and bnfpo = int_zvs13-posnr.

check sy-subrc = 0.

* for 3rd party we check eban-pstyp = '5' "$4


* knttp can be either e or m "$4
* if eban-knttp = 'e' or " old code for sales stock item"$4
* eban-knttp = 'm' or " new code for sales stock item"$4
* eban-bsart = 'z3'. " third party requisition "$4
* else. "$4
* exit. "$4
* endif. "$4
clear ws_vbeln.
clear ws_posnr.

select single *
from ebkn
where banfn = eban-banfn
and bnfpo = eban-bnfpo.
if sy-subrc = 0.
ws_vbeln = ebkn-vbeln.
ws_posnr = ebkn-vbelp.
endif.

if ws_vbeln is initial or
ws_posnr is initial.
exit.
endif.

** check b2b order with wbna user status


* clear ws_objnr_tab. "$4
* clear ws_wbna_status. "$4
* concatenate 'vb' ws_vbeln '000000' into ws_objnr_tab-objnr. "$4
* append ws_objnr_tab. "$4
* call function 'status_read_multi' "$4
* exporting "$4
* client = sy-mandt "$4
* only_active = 'x' "$4
* tables "$4
* objnr_tab = ws_objnr_tab "$4
* status = ws_status_tab. "$4
* "$4
* loop at ws_status_tab. "$4
* check ws_status_tab-stat = 'e0011'. "user status = wbna "$4
* move 'x' to ws_wbna_status. "$4
* exit. "$4
* endloop. "$4
* "$4
* "$4
* for third party requisition , its corresponding item in sales doc. may
* "$4
* not be blocked for screening. anything that blocks that sales doc. "$4
* could block the requisition. "$4
* "$4
if eban-pstyp = '5'. "$4 third party requisition
* "$4 different test in europe
select * "$4
from zvs13 "$4
into table item_zvs13 "$4
where vbeln = ws_vbeln "$4
and ( stonr = 20 or "$4
stonr = 30 or "$4
stonr = 50 ). "$4
else. "$4
select *
from zvs13
into table item_zvs13
where vbeln = ws_vbeln
and posnr = ws_posnr
and ( stonr = 20 or "$6
stonr = 30 or "$6
stonr = 50 ). "$6
endif. "$4

describe table item_zvs13 lines lin_no.

** if it's b2b order with wbna user status then display message
* if ws_wbna_status = 'x'. "$4
* move 1 to lin_no. "$4
* endif. "$4

check lin_no > 0.

select * from zvs24t


where zpopup = 'saleordstk'
and spras = sy-langu.
endselect.
if sy-subrc = 0.
move zvs24t-zpopdes to field.
else.
move 'sales order stock - must release order first' to field.
endif.

concatenate 'sales order ' ws_vbeln


'item ' ws_posnr into field1 separated by ' '.

move 'order screening - queue management' to popup_title.

call function 'popup_to_display_text'


exporting
titel = popup_title
textline1 = field
textline2 = field1
exceptions
others = 1.

endform. "check_sales_order_stock
*eject
*---------------------------------------------------------------------*
* form release_requisition_sos_block *
*---------------------------------------------------------------------*
form release_requisition_sos_block.

data: w_sos_item(1). "$9


data: w_werks type werks_d. "$10
data: w_zcland like zvs13-zcland. "$10

if vbak-vbeln < c_purchase_requisition_high and " purchase requisition


vbak-vbeln >= c_purchase_requisition_low.
exit.
endif.

select single *
from vbap
where vbeln = int_zvs13-vbeln
and posnr = ck_tab-posnr.
check sy-subrc = 0.
* don't proceed with this check if this is a short shelf life product"$6
* i.e. genosys because this is also knttp = 'e'. "$6
read table t_zgenpstyvheadblk "$6
with key pstyv = vbap-pstyv. "$6

check sy-subrc <> 0. "$6

select *
from vbep
into table xvbep
where vbeln = vbap-vbeln
and posnr = vbap-posnr.

if t_tvep[] is initial. "$9


select ettyp "$9
pstyp "$9
knttp "$9
from tvep "$9
into corresponding fields of table t_tvep. "$9
endif. "$9

* need to check if this is a sales order stock item


loop at xvbep. "$9

* find the tvep entry for the schedule line item category

read table t_tvep with key ettyp = xvbep-ettyp. "$9


check sy-subrc = 0. "$9

* is this a sales order stock item

if t_tvep-pstyp = '0' and "$9


t_tvep-knttp = 'e'. "$9
w_sos_item = 'x'. "$9
exit. "$9
endif. "$9
endloop. "$9

check w_sos_item = 'x'. "$9

loop at xvbep.

if xvbep-banfn is initial or
xvbep-bnfpo is initial.
continue.
endif.

w_zcland = int_zvs13-zcland. "$10


perform get_pr_plant_country using xvbep-banfn "$10
xvbep-bnfpo "$10
changing w_zcland. "$10

update zvs13
set stonr = 40
name1_gp = sy-uname
zabdat = sy-datum
aenam = sy-uname
laeda = sy-datum
lauhr = sy-uzeit
zabtim = sy-uzeit
where zcland = w_zcland "$10
and vbeln = xvbep-banfn
and posnr = xvbep-bnfpo
and zqueid = 'sosblock'
and stonr = 30.

* if pruchase requisition is deleted then no need to release it


check eban-loekz is initial. "$4

* if there is no zvs13 entry with queuid 'sosblock' created


* then that means the item must have failed the pr screening
* and will still have other zvs13 entries not released.
* therefore, do not release pr strategy at this point.
if sy-subrc = 0.
perform requisition_strategy_release using xvbep-banfn
xvbep-bnfpo.
endif.
perform unlock_purchase_requisition.

endloop.

endform. "release_requisition_sos_block
*eject
*---------------------------------------------------------------------*
* form release_third_party_sos_block *
*---------------------------------------------------------------------*
form release_third_party_sos_block. "$4
* "$4
if vbak-vbeln < c_purchase_requisition_high and " purchase requisition
"$4
vbak-vbeln >= c_purchase_requisition_low. "$4
exit. "$4
endif. "$4
* "$4
select * from vbep into table xvbep "$4
where vbeln = vbak-vbeln. "$4
loop at xvbep. "$4
* "$4
if xvbep-banfn is initial or "$4
xvbep-bnfpo is initial. "$4
continue. "$4
endif. "$4
* "$4
select single * from tvep "$4
where pstyp = '5' "$4third party item category
and ettyp = xvbep-ettyp. "$4schedule line category
check sy-subrc = 0. "$4third party item
* "$4
select single * from eban where banfn = xvbep-banfn "$4
and bnfpo = xvbep-bnfpo. "$4
check sy-subrc = 0. "$4
* "$4
update zvs13 "$4
set stonr = 40 "$4
name1_gp = sy-uname "$4
zabdat = sy-datum "$4
aenam = sy-uname "$4
laeda = sy-datum "$4
lauhr = sy-uzeit "$4
zabtim = sy-uzeit "$4
* removed check for specific zcland "$4
where vbeln = xvbep-banfn "$4
and posnr = xvbep-bnfpo "$4
and zqueid = 'sosblock' "$4
and stonr = 30. "$4
* "$4
* if pruchase requisition is deleted then no need to release it "$4
check eban-loekz is initial. "$4
* "$4
* if there is no zvs13 entry with queuid 'sosblock' created "$4
* then that means the item must have failed the pr screening "$4
* and will still have other zvs13 entries not released. "$4
* therefore, do not release pr strategy at this point. "$4
if sy-subrc = 0. "$4
perform requisition_strategy_release using xvbep-banfn "$4
xvbep-bnfpo. "$4
endif. "$4
perform unlock_purchase_requisition. "$4
* "$4
endloop. "$4
* "$4
endform. "release_third_party_sos_block "$4
*eject "$4
*---------------------------------------------------------------------*
* form check_third_party_sos_block *
*---------------------------------------------------------------------*
form check_third_party_sos_block. "$4

* data: begin of xvbep occurs 10. "$4


* include structure vbep. "$4
* data: end of xvbep. "$4
* "$4
* data: ws_check_third_party(1). "$4
* "$4
if vbak-vbeln < c_purchase_requisition_high and " purchase requisition
"$4
vbak-vbeln >= c_purchase_requisition_low. "$4
exit. "$4
endif. "$4
* "$4
move 'x' to all_third_party_item_released. "$4
* "$4
select * from vbep into table xvbep "$4
where vbeln = vbak-vbeln. "$4
loop at xvbep. "$4
* "$4
if xvbep-banfn is initial or "$4
xvbep-bnfpo is initial. "$4
continue. "$4
endif. "$4
* "$4
select single * from tvep "$4
where pstyp = '5' "third party item category "$4
and ettyp = xvbep-ettyp. "schedule line category "$4
check sy-subrc = 0. "third party item "$4
* "$4
clear int_ship. "$4
refresh int_ship. "$4
select * "$4
from zvs13 "$4
into table int_ship "$4
where vbeln = xvbep-vbeln "$4
and posnr = xvbep-posnr "$4
and ( stonr = 20 or "$4
stonr = 30 or "$4
stonr = 50 ). "$4
describe table int_ship lines lin_no. "$4
if lin_no > 0. "$4
continue. "$4
endif. "$4
* "$4
update zvs13 "$4
set stonr = 40 "$4
name1_gp = sy-uname "$4
zabdat = sy-datum "$4
aenam = sy-uname "$4
laeda = sy-datum "$4
lauhr = sy-uzeit "$4
zabtim = sy-uzeit "$4
*$4 remove check for country specific zcland "$4
where vbeln = xvbep-banfn "$4
and posnr = xvbep-bnfpo "$4
and zqueid = 'sosblock' "$4
and stonr = 30. "$4
* "$4
* if purchase requisition is deleted then no need to release it "$4
check eban-loekz is initial. "$4
* "$4
* if there is no zvs13 entry with queuid 'sosblock' created "$4
* then that means the item must have failed the pr screening "$4
* and will still have other zvs13 entries not released. "$4
* therefore, do not release pr strategy at this point. "$4
if sy-subrc = 0. "$4
perform requisition_strategy_release using xvbep-banfn "$4
xvbep-bnfpo. "$4
endif. "$4
* perform unlock_purchase_requisition. "$4
* "$4
endloop. "$4
* "$4
endform. "check_third_party_sos_block "$4
*eject "$4
*---------------------------------------------------------------------*
* form check_line_item_comp_reasons *
*---------------------------------------------------------------------*
form check_line_item_comp_reasons.

if vbak-vbeln < c_purchase_requisition_high and " purchase requisition


vbak-vbeln >= c_purchase_requisition_low.
* perform requisition_strategy_release using vbak-vbeln ck_tab-posnr.
* perform unlock_purchase_requisition.
exit.
endif.

select *
from zvs13
into table item_zvs13
where vbeln = vbak-vbeln
and posnr = ck_tab-posnr.
move 'x' to update_item_status.
loop at item_zvs13.
if item_zvs13-stonr = 20 or
item_zvs13-stonr = 30.
move ' ' to update_item_status.
continue.
endif.
endloop.
if update_item_status = 'x'.
perform lock_sales_document.
perform update_line_item_status.
perform unlock_sales_document.
perform release_requisition_sos_block.

* now look at the materials that have short shelf life i.e. genosys
* so we do not release the pr until header level screening is ok
perform release_requisition_sls_block. "$6
endif.
endform. "check_line_item_comp_reasons
*eject
*---------------------------------------------------------------------*
* form requisition_strategy_release *
*---------------------------------------------------------------------*
form requisition_strategy_release using ws_banfn ws_bnfpo.

data: ws_release_code like bapimmpara-rel_code.


data: ws_bapi_banfn like bapi2009ob-preq_no.
data: ws_bapi_bnfpo like bapi2009ob-preq_item.

select *
from zvs13
into table item_zvs13
where vbeln = ws_banfn
and posnr = ws_bnfpo
and stonr = 30.
describe table item_zvs13 lines lin_no.
if lin_no > 1. " not all released
* if sy-subrc = 0. " not all released
exit. " do not release strategy
endif.

select single * from eban where banfn = ws_banfn


and bnfpo = ws_bnfpo.
check sy-subrc = 0.

if eban-frgst = 'ss'. " sales order stock strategy


if eban-frgkz = 'o'. " strategy already been released
exit.
else.
move 'ss' to ws_release_code.
endif.
else.
if eban-frgkz = 'r'. " strategy already been released
exit.
else.
move 'sr' to ws_release_code.
endif.
endif.

move ws_banfn to ws_bapi_banfn.


move ws_bnfpo to ws_bapi_bnfpo.
call function 'bapi_requisition_release'
exporting
number = ws_bapi_banfn
rel_code = ws_release_code
item = ws_bapi_bnfpo.

endform. "requisition_strategy_release
*eject
*---------------------------------------------------------------------*
* form lock_sales_document *
*---------------------------------------------------------------------*
form lock_sales_document.
call function 'enqueue_evvbake'
exporting
vbeln = vbak-vbeln
exceptions
foreign_lock = 2
system_failure = 3.
endform. "lock_sales_document
*eject
*---------------------------------------------------------------------*
* form lock_purchase requisition *
*---------------------------------------------------------------------*
form lock_purchase_requisition.
data: ws_bnfpo like eban-bnfpo.
move int_zvs13-posnr to ws_bnfpo.
call function 'enqueue_emebane'
exporting
banfn = vbak-vbeln
bnfpo = ws_bnfpo
exceptions
foreign_lock = 2
system_failure = 3.
case sy-subrc.
when '0000'.
perform unlock_purchase_requisition.
when '0002'.
message e006(me) with sy-msgv1 'purch. requisition' vbak-vbeln
space.
move 'n' to has_security.
when '0003'.
message e007(me) with text-005 vbak-vbeln.
move 'n' to has_security.
when others.
move 'n' to has_security.
endcase.
endform. "lock_purchase_requisition
*eject
*---------------------------------------------------------------------*
* form unlock_sales_document *
*---------------------------------------------------------------------*
form unlock_sales_document.
call function 'dequeue_evvbake'
exporting
vbeln = vbak-vbeln.
endform. "unlock_sales_document
*eject
*---------------------------------------------------------------------*
* form unlock_purhase requisition *
*---------------------------------------------------------------------*
form unlock_purchase_requisition.
data: ws_bnfpo like eban-bnfpo.
move int_zvs13-posnr to ws_bnfpo.
call function 'dequeue_emebane'
exporting
banfn = vbak-vbeln
bnfpo = ws_bnfpo.
endform. "unlock_purchase_requisition
*eject
*---------------------------------------------------------------------*
* form update_line_item_status *
*---------------------------------------------------------------------*
form update_line_item_status.
if ck_tab-posnr = '000000'.
exit.
endif.
concatenate 'vb' vbak-vbeln ck_tab-posnr into object_number.
perform get_change_number.
move 'x' to update_item_status.
select * from jest into table *jest
where objnr = object_number and
inact = ' '.
if sy-subrc = 0.
loop at *jest.
if *jest-stat = 'e0005'.
move ' ' to update_item_status.
endif.
if *jest-stat = 'e0002' or
*jest-stat = 'e0003' or
*jest-stat = 'e0001'.
move 'x' to *jest-inact.
modify *jest.
endif.
endloop.
if update_item_status = 'x'.
move object_number to *jest-objnr.
move 'e0004' to *jest-stat.
move ' ' to *jest-inact.
move change_number to *jest-chgnr.
append *jest.
endif.
modify jest from table *jest.
endif.
perform update_jcds.
endform. "update_line_item_status
*eject
*---------------------------------------------------------------------*
* form update_jcds *
*---------------------------------------------------------------------*
form update_jcds.
select * from jcds into table *jcds
where objnr = object_number and
inact = ' '.
if sy-subrc = 0.
loop at *jcds.
if *jcds-stat = 'e0002' or
*jcds-stat = 'e0003' or
*jcds-stat = 'e0004' or
*jcds-stat = 'e0001'.
move 'x' to *jcds-inact.
modify *jcds.
endif.
endloop.
move object_number to *jcds-objnr.
move 'e0004' to *jcds-stat.
move ' ' to *jcds-inact.
move change_number to *jcds-chgnr.
move sy-uname to *jcds-usnam.
move sy-datum to *jcds-udate.
move sy-uzeit to *jcds-utime.
move sy-tcode to *jcds-tcode.
move 'u' to *jcds-chind.
append *jcds.
modify jcds from table *jcds.
endif.
endform. "update_jcds
*eject
*&---------------------------------------------------------------------*
*& form update_header_status
*&---------------------------------------------------------------------*
* change of header status to sc0k
*&---------------------------------------------------------------------*
form update_header_status.
if vbak-vbeln < c_purchase_requisition_high and " purchase requisition
vbak-vbeln >= c_purchase_requisition_low.
loop at ck_tab.
delete itab where vbeln = ck_tab-vbeln
and posnr = ck_tab-posnr
and zcomrea = ck_tab-zcomrea
and zqueid = ck_tab-zqueid
and zcland = ck_tab-zcland
and zcomgrp = ck_tab-zcomgrp
and zcomtyp = ck_tab-zcomtyp
and zlictyp = ck_tab-zlictyp.
endloop.
exit.
endif.

select *
from zvs13
into table item_zvs13
where vbeln = vbak-vbeln.
move 'x' to update_header_status.
loop at item_zvs13.
if ( ( item_zvs13-stonr = 20 ) or
( item_zvs13-stonr = 30 ) ) and
( item_zvs13-zcomrea <> 57 ) and
( item_zvs13-zcomrea <> 61 ) and
( item_zvs13-zcomrea <> 62 ) and
( item_zvs13-zcomrea <> 63 ) and
( item_zvs13-zcomrea <> 65 ).
move ' ' to update_header_status.
exit.
endif.
endloop.
if update_header_status = 'x'.

* this sosblock refers to the name of the block and is not limited to
* sales order stock. e.g. mayflower and genosys products are included
* if a sales order has a screening block then we do not want the
* corresponding purchase requisition to be available so we artifically
* apply an "sosbli=ock" to the pr item that eventually has to be
* released automaticlaly rather than by a user. this release is
* happening here if all relevant conditions are satisfied.

perform release_third_party_sos_block. "$4


perform release_short_life_sos_block. "$6
concatenate 'vb' vbak-vbeln '000000' into object_number.
perform get_change_number.
select * from jest into table *jest
where objnr = object_number and
inact = ' '.
if sy-subrc = 0.
loop at *jest.
if *jest-stat = 'e0002' or
*jest-stat = 'e0003' or
*jest-stat = 'e0001'.
move 'x' to *jest-inact.
modify *jest.
endif.
endloop.
move 'e0004' to *jest-stat.
move ' ' to *jest-inact.
move change_number to *jest-chgnr.
append *jest.
modify jest from table *jest.
endif.
perform update_jcds.
commit work and wait. "$5
perform send_genosys_items. "$5
commit work and wait. "$5
endif.
if sy-subrc = 0.
loop at ck_tab.
delete itab
where vbeln = ck_tab-vbeln
and posnr = ck_tab-posnr
and zcomrea = ck_tab-zcomrea
and zqueid = ck_tab-zqueid
and zcland = ck_tab-zcland
and zcomgrp = ck_tab-zcomgrp
and zcomtyp = ck_tab-zcomtyp
and zlictyp = ck_tab-zlictyp.
endloop.
endif.
endform. " update_header_status
*eject
*---------------------------------------------------------------------*
* form get_change_number *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form get_change_number.
select chgnr into change_number from jest
where objnr = object_number and stat = 'e0004'
order by chgnr.
endselect.
if sy-subrc = 0.
add 1 to change_number.
else.
move 1 to change_number.
endif.
endform. "get_change_number
*eject
*&---------------------------------------------------------------------*
*& module line_count output
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
module line_count output.
bas = sy-loopc + 1.
endmodule. " line_count output
*&---------------------------------------------------------------------*
module sigma output.
endmodule. " sigma output
*&---------------------------------------------------------------------*
*& module read_itab output
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
module read_itab output.
endmodule. " read_itab output
*&---------------------------------------------------------------------*
*& form ques
*&---------------------------------------------------------------------*
* selection of other queid for the order
*----------------------------------------------------------------------*
form ques.
if w_zcland is initial.
select *
from zvs13
where vbeln = vbak-vbeln
and ( stonr <> 40 )
and ( stonr <> 50 )
and ( zqueid <> int_zvs13-zqueid ).
endselect.
if sy-subrc = 0.
select *
from zvs13
into table int_zvs13
where vbeln = vbak-vbeln
and stonr <> 40
and stonr <> 50.
.
describe table int_zvs13 lines lin_no.
* loop at int_zvs13.
* if exclude_delayed = 'x'.
* if int_zvs13-zohind = 'x'.
* if int_zvs13-zohdat > sy-datum.
* delete int_zvs13 where zohdat > sy-datum.
* exit.
* elseif int_zvs13-zohdat = sy-datum and int_zvs13-zohtim > sy-uzeit.
* delete int_zvs13 where zohtim > sy-uzeit.
* exit.
* endif.
* endif.
* endif.
* if only_delayed = 'x'.
* if int_zvs13-zohdat < sy-datum.
* delete int_zvs13 where zohdat < sy-datum.
* exit.
* elseif int_zvs13-zohdat = sy-datum and
* int_zvs13-zohtim < sy-uzeit.
* delete int_zvs13 where zohtim < sy-uzeit.
* exit.
* endif.
* endif.
* endloop.
else.

select * from zvs24t


where zpopup = 'queues'
and spras = sy-langu.
endselect.
if sy-subrc = 0.
move zvs24t-zpopdes to popup_text1.
move zvs24t-zpopdes+35(35) to popup_text2.
else.
move ' additional queue entries ' to popup_text1.
move ' do not exist ' to popup_text2.
endif.

call function 'popup_to_display_text'


exporting
titel = ' order screening queue management '
textline1 = popup_text1
textline2 = popup_text2
exceptions
others = 1.
if sy-ucomm = 'yes'.
set screen 300. leave screen.
endif.
endif.
else.
select *
from zvs13
where vbeln = vbak-vbeln
and ( stonr <> 40 )
and ( stonr <> 50 )
and ( zqueid <> int_zvs13-zqueid )
and ( zcland = w_zcland ).
endselect.
if sy-subrc = 0.
select *
from zvs13
into table int_zvs13
where vbeln = vbak-vbeln
and stonr <> 40
and stonr <> 50.

describe table int_zvs13 lines lin_no.


else.

select * from zvs24t


where zpopup = 'queues'
and spras = sy-langu.
endselect.
if sy-subrc = 0.
move zvs24t-zpopdes to popup_text1.
move zvs24t-zpopdes+35(35) to popup_text2.
else.
move ' additional queue entries ' to popup_text1.
move ' do not exist ' to popup_text2.
endif.

call function 'popup_to_display_text'


exporting
titel = ' order screening queue management '
textline1 = popup_text1
textline2 = popup_text2
exceptions
others = 1.
if sy-ucomm = 'yes'.
set screen 300. leave screen.
endif.
endif.

endif.

endform. " ques


*&---------------------------------------------------------------------*
*& form neor
*&---------------------------------------------------------------------*
* the items selected in the summary screen are showed in
* order in review screen
*----------------------------------------------------------------------*
form neor using ccode.
* case ccode.

if *zvs50-vbeln = vbak-vbeln.
delete *zvs50 where vbeln = vbak-vbeln and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = vbak-vbeln and ernam = sy-uname.
endif.
loop at *zvs50.
if *zvs50-vbeln = int_zvs13-vbeln.
delete *zvs50 where vbeln = int_zvs13-vbeln and ernam = sy-uname.
delete from zvs50 where vbeln = int_zvs13-vbeln and ernam = sy-uname.
endif.
endloop.
describe table chk_tab lines lin_no.
if num1 < lin_no.
num1 = num1 + 1.
if num1 > 1.
endif.
read table chk_tab index num1.
else.
loop at itab.

if *zvs50-vbeln = vbak-vbeln.
delete *zvs50 where vbeln = vbak-vbeln and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = vbak-vbeln and ernam = sy-uname.
endif.
loop at *zvs50.
if *zvs50-vbeln = int_zvs13-vbeln.
delete *zvs50 where vbeln = int_zvs13-vbeln and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = int_zvs13-vbeln and ernam = sy-uname.
endif.
endloop.
* loop at itab.
move ' ' to itab-chekbox.
modify itab.
move itab-chekbox to sitab-sol_col.
append sitab.
endloop.
set screen 200.
leave screen.
endif.
* endcase.
endform. " neor
*&---------------------------------------------------------------------*
*& form change
*&---------------------------------------------------------------------*
form change.
* if vbak-vbeln < c_delivery_low. "$12
" purchase requisition
if vbak-vbeln < c_purchase_requisition_high and
vbak-vbeln >= c_purchase_requisition_low.
set parameter id 'ban' field vbak-vbeln.
call transaction 'me52n' and skip first screen.
else.
clear seenu.
refresh seenu.
select * from vbak into table seenu where vbeln = vbak-vbeln.
loop at seenu.
endloop.
if seenu-vbeln = ' '.
clear field.
concatenate 'document' vbak-vbeln 'does not exist' into field
separated by ' '.
call function 'popup_to_display_text'
exporting
titel = 'order screening - queue management'
textline1 = field
exceptions
others = 1.
else.
if seenu-vbtyp = 'c'.
set parameter id 'aun' field vbak-vbeln.
call transaction 'va02' and skip first screen.
endif.
if seenu-vbtyp = 'e'.
set parameter id 'lpn' field vbak-vbeln.
call transaction 'va32' and skip first screen.
endif.
if seenu-vbtyp = 'b'.
set parameter id 'aun' field vbak-vbeln.
call transaction 'va22' and skip first screen.
endif.
call function 'addr_memory_clear'
exporting
force = 'x'
exceptions
unsaved_data_exist = 1
internal_error = 2
others = 3.
clear sy-subrc.
do 10000 times.
call function 'sd_sales_document_enqueue'
exporting
vbeln = vbak-vbeln
exceptions
foreign_lock = 1
system_failure = 2
others = 3.

if sy-subrc = 0.
call function 'dequeue_evvbake'
exporting
mandt = sy-mandt
vbeln = vbak-vbeln
_collect = ' '.
clear sy-subrc.
exit.
endif.
enddo.
endif.
endif.
* else. "$12
* clear seenu1. "$12
* select * from likp into table seenu1 where vbeln = vbak-vbeln. "$12
* loop at seenu1. "$12
* endloop. "$12
* if seenu1-vbtyp = 'j'. "$12
* call transaction 'vl02n' and skip first screen. "$12
* endif. "$12
* endif. "$12
endform. " change
*&---------------------------------------------------------------------*
*& form disp
*&---------------------------------------------------------------------*

form display.
clear seenu.
* if vbak-vbeln < c_delivery_low. "$12
" purchase requisition
if vbak-vbeln < c_purchase_requisition_high and
vbak-vbeln >= c_purchase_requisition_low.
set parameter id 'ban' field vbak-vbeln.
call transaction 'me53n' and skip first screen.
else.
select * from vbak into table seenu where vbeln = vbak-vbeln.
loop at seenu.
endloop.
if seenu-vbeln = ' '.
clear field.
concatenate 'document' vbak-vbeln 'does not exist' into field
separated by ' '.
call function 'popup_to_display_text'
exporting
titel = 'order screening - queue management'
textline1 = field
exceptions
others = 1.
else.
if seenu-vbtyp = 'c' or seenu-vbtyp = 'i'.
set parameter id 'aun' field vbak-vbeln.
call transaction 'va03' and skip first screen.
endif.
if seenu-vbtyp = 'e'.
set parameter id 'lpn' field vbak-vbeln.
call transaction 'va33' and skip first screen.
endif.
if seenu-vbtyp = 'b'.
set parameter id 'aun' field vbak-vbeln.
call transaction 'va23' and skip first screen.
endif.
endif.
endif.
* else. "$12
* select * from likp into table seenu1 where vbeln = vbak-vbeln. "$12
* loop at seenu1. "$12
* endloop. "$12
* if seenu1-vbtyp = 'j'. "$12
* call transaction 'vl03' and skip first screen. "$12
* endif. "$12
* endif. "$12

endform. " display


*&---------------------------------------------------------------------*
*& form dela
*&---------------------------------------------------------------------*
* security check for user profiles and holding the order with date and
* time
*----------------------------------------------------------------------*
form delay.
refresh ck_tab.
loop at int_zvs13.
if int_zvs13-checkbox = 'x'.
select single * from zvs48
where zcland = int_zvs13-zcland and
uname = sy-uname and
zqueid = int_zvs13-zqueid.
if sy-subrc <> 0.
select * from zvs48 into table int_zvs48 where uname = sy-uname and
zqueid = int_zvs13-zqueid.
if sy-subrc <> 0.
call screen 500 starting at 11 06 ending at 50 13.
else.
move 'n' to has_security.
loop at int_zvs48.
select single * from zvs07 where zctygrp = int_zvs48-zcomgrp and
zland = int_zvs13-zcland.
if sy-subrc = 0.
move 'y' to has_security.
endif.
endloop.
if has_security = 'y'.
move-corresponding int_zvs13 to ck_tab.
append ck_tab.
else.
call screen 500 starting at 11 06 ending at 50 13.
endif.
endif.
else.
move-corresponding int_zvs13 to ck_tab.
append ck_tab.
endif.
endif.
endloop.
data: returncode(1).
loop at ck_tab.
clear: fields.
clear: fields[].
fields-tabname = 'syst'.
fields-fieldname = 'datum'.
fields-fieldtext = 'on hold until date'.
fields-value = until_date.
append fields.
fields-tabname = 'syst'.
fields-fieldname = 'uzeit'.
fields-fieldtext = 'on hold until time'.
fields-value = until_time.
append fields.
clear popup_title.
concatenate 'queue management - item' ck_tab-posnr into
popup_title separated by ' '.
call function 'popup_get_values'
exporting
popup_title = popup_title
start_column = '5'
start_row = '5'
importing
returncode = returncode
tables
fields = fields
exceptions
error_in_fields = 1
others = 2.
check returncode <> 'a'.
loop at fields.
if fields-fieldname = 'datum'.
if fields-value ne '00000000'.
move fields-value to until_date.
else.
exit.
endif.
endif.
if fields-fieldname = 'uzeit'.
if fields-value ne '000000'.
move fields-value to until_time.
else.
exit.
endif.
endif.
endloop.
if until_date ne '00000000'.
if until_time ne '000000'.
update zvs13 set zohdat = until_date
zohtim = until_time
zohind = 'x'
aenam = sy-uname
laeda = sy-datum
lauhr = sy-uzeit
where zcland = ck_tab-zcland and
zcomgrp = ck_tab-zcomgrp and
vbeln = ck_tab-vbeln and
posnr = ck_tab-posnr and
zcomrea = ck_tab-zcomrea and
zseqno = ck_tab-zseqno and
zcomtyp = ck_tab-zcomtyp and
zlictyp = ck_tab-zlictyp.
if sy-subrc = 0.
move until_date to ck_tab-zohdat.
move until_time to ck_tab-zohtim.
modify ck_tab.
if exclude_delayed = 'x'.
delete itab
where vbeln = ck_tab-vbeln and posnr = ck_tab-posnr
and zcomrea = ck_tab-zcomrea
and zqueid = ck_tab-zqueid.
endif.
endif.
endif.
endif.
endloop.
endform. " delay
*---------------------------------------------------------------------*
* form shippable *
*---------------------------------------------------------------------*
form shippable.
concatenate 'vb' vbak-vbeln '000000' into object_number.
perform get_change_number.
select * from jest into table *jest
where objnr = object_number and
inact = ' '.
if sy-subrc = 0.
loop at *jest.
if *jest-stat = 'e0002' or
*jest-stat = 'e0003' or
*jest-stat = 'e0001'.
move 'x' to *jest-inact.
modify *jest.
endif.
endloop.
move 'e0004' to *jest-stat.
move ' ' to *jest-inact.
move change_number to *jest-chgnr.
append *jest.
modify jest from table *jest.
endif.

endform. "shippable
*&---------------------------------------------------------------------*
*& module user_command_0500 input
*&---------------------------------------------------------------------*
module user_command_0500 input.
if sy-ucomm = 'cont' or
sy-ucomm = 'canc'.
set screen 0.
leave screen.
endif.
endmodule. " user_command_0500 input
*&---------------------------------------------------------------------*
*& module status_0500 output
*&---------------------------------------------------------------------*
module status_0500 output.
set pf-status '500'.
set titlebar 'q50'.

endmodule. " status_0500 output


*&---------------------------------------------------------------------*
*& module status_0600 output
*&---------------------------------------------------------------------*
module status_0600 output.
set pf-status 'zseen'.
set titlebar 'zik'.
endmodule. " status_0600 output
*&---------------------------------------------------------------------*
*& module user_command_0600 input
*&---------------------------------------------------------------------*
module user_command_0600 input.
if sy-ucomm = 'cont'.
set screen 0.
leave screen.
endif.
endmodule. " user_command_0600 input
*&---------------------------------------------------------------------*
*& form furl
*&---------------------------------------------------------------------*
* if the itmes are released then you should see on the review screen.
*----------------------------------------------------------------------*
form furl.

if chk_tab-chekbox = 'x'.
move chk_tab-vbeln to vbak-vbeln.

if vbak-vbeln < c_purchase_requisition_high and "$3


"purchase requisition
vbak-vbeln >= c_purchase_requisition_low. "$3
refresh itvtab.
select *
from zvs13
into table itvtab
where vbeln = vbak-vbeln.
loop at itvtab.
move itvtab-zshipno to vbak-kunnr.
move itvtab-kunnr to kna1-kunnr.
endloop.
else. "$3
select * "$3
from vbpa "$3
into corresponding fields of table t_vbpa "$3
where vbeln = vbak-vbeln "$3
and posnr = '000000'. "$3

loop at t_vbpa. "$3


if t_vbpa-parvw = 'ag'. "$3
move t_vbpa-kunnr to kna1-kunnr. "$3
elseif t_vbpa-parvw = 'we'. "$3
move t_vbpa-kunnr to vbak-kunnr. "$3
endif. "$3
endloop. "$3
endif. "$3

clear kna1-name1.
clear kna1-name2.
clear kna1-name3.
clear kna1-name4.
clear kna1-ort01.
clear kna1-stras.
clear kna1-regio.
clear kna1-land1.
clear kna1-pstlz.
refresh ktab.

refresh ktab1.
clear name1.
clear name2.
clear name3.
clear name4.
clear ort01.
clear stras.
clear regio.
clear land.
clear pstlz.
select * from kna1 into table ktab
where kunnr = kna1-kunnr.
if sy-subrc = 0.
loop at ktab.
move ktab-name1 to kna1-name1.
move ktab-name2 to kna1-name2.
move ktab-name3 to kna1-name3.
move ktab-name4 to kna1-name4.
move ktab-ort01 to kna1-ort01.
move ktab-stras to kna1-stras.
move ktab-regio to kna1-regio.
move ktab-land1 to kna1-land1.
move ktab-pstlz to kna1-pstlz.
endloop.
else.
clear ktab.
endif.
refresh ktab2.
* refresh ksadr.
select *
from vbpa
into table vbpa1
where vbeln = vbak-vbeln
and posnr = '000000' "$14
and parvw = 'ap'.

sy-subrc = 4. "$2
if sy-subrc <> 0 .
select *
from vbpa
into table vbpa1
where vbeln = vbak-vbeln
and posnr = '000000' "$14
and parvw = 'we'.

if sy-subrc <> 0.
select * from kna1 into table ktab2
where kunnr = kna1-kunnr.
loop at ktab2.
move ktab2-name1 to name1.
move ktab2-name2 to name2.
move ktab2-name3 to name3.
move ktab2-name4 to name4.
move ktab2-ort01 to ort01.
move ktab2-regio to regio.
move ktab2-land1 to w_land1.
move ktab2-pstlz to pstlz.
endloop.
else.
* refresh ksadr.
loop at vbpa1.
perform get_sadr_address using vbpa1-adrnr.
* select * from sadr into table ksadr
* where adrnr = vbpa1-adrnr.
endloop.
if vbpa1-adrnr is initial.
select * from kna1 into table ktab2
where kunnr = vbak-kunnr.
loop at ktab2.
move ktab2-name1 to name1.
move ktab2-name2 to name2 .
move ktab2-name3 to name3 .
move ktab2-name4 to name4 .
move ktab2-ort01 to ort01 .
move ktab2-stras to stras .
move ktab2-regio to regio.
move ktab2-land1 to land.
move ktab2-pstlz to pstlz.
endloop.

else.
* loop at ksadr.
move ksadr-name1 to name1.
move ksadr-name2 to name2.
move ksadr-name3 to name3.
move ksadr-name4 to name4.
move ksadr-ort01 to ort01.
move ksadr-stras to stras.
move ksadr-regio to regio.
move ksadr-land1 to land.
move ksadr-pstlz to pstlz.
* endloop.
endif.
endif.
else.
perform contact_person_address.
endif.
if w_zqueid is initial and
w_zcland is initial.
select *
from zvs13
into table int_zvs13
where ( vbeln = vbak-vbeln )
and stonr <> 40
and stonr <> 50.
elseif not w_zqueid is initial.
select *
from zvs13
into table int_zvs13
where ( vbeln = vbak-vbeln )
and stonr <> 40
and stonr <> 50
and zqueid = w_zqueid.
elseif not w_zcland is initial.
select *
from zvs13
into table int_zvs13
where ( vbeln = vbak-vbeln )
and stonr <> 40
and stonr <> 50
and ( zcland = w_zcland ).
endif.
endif.
endform. " furl
*eject
*&---------------------------------------------------------------------*
*& form record_change
*&---------------------------------------------------------------------*
* when there is a change made in va02 then you see the added records
* in the review screen.
*----------------------------------------------------------------------*
form record_change.
if vbak-vbeln < c_purchase_requisition_high and " purchase requisition
vbak-vbeln >= c_purchase_requisition_low.
exit.
endif.

select *
from vbpa
into corresponding fields of table t_vbpa
where vbeln = vbak-vbeln
and posnr = '000000'.

loop at t_vbpa.
if t_vbpa-parvw = 'ag'.
move t_vbpa-kunnr to kna1-kunnr.
elseif t_vbpa-parvw = 'we'.
move t_vbpa-kunnr to vbak-kunnr.
endif.
endloop.

clear kna1-name1.
clear kna1-name2.
clear kna1-name3.
clear kna1-name4.
clear kna1-ort01.
clear kna1-stras.
clear kna1-regio.
clear kna1-land1.
clear kna1-pstlz.
refresh ktab.

refresh ktab1.
clear name1.
clear name2.
clear name3.
clear name4.
clear ort01.
clear stras.
clear regio.
clear land.
clear pstlz.
select * from kna1 into table ktab
where kunnr = kna1-kunnr.
if sy-subrc = 0.
select single *
from vbpa
where vbeln = vbak-vbeln
and parvw = 'ag'
and posnr = '000000'.
if sy-subrc = 0 and
ktab-adrnr = vbpa-adrnr. "check whether the address has changed
loop at ktab.
move ktab-name1 to kna1-name1.
move ktab-name2 to kna1-name2.
move ktab-name3 to kna1-name3.
move ktab-name4 to kna1-name4.
move ktab-ort01 to kna1-ort01.
move ktab-stras to kna1-stras.
move ktab-regio to kna1-regio.
move ktab-land1 to kna1-land1.
move ktab-pstlz to kna1-pstlz.
endloop.
endif.
else.
clear ktab.
endif.

read table t_vbpa with key vbeln = vbak-vbeln


posnr = '000000'
parvw = 'ag'.
if sy-subrc = 0.
if vbpa-adrda = 'e'. " manual address
perform get_sadr_address using vbpa-adrnr.
move ksadr-name1 to kna1-name1.
move ksadr-name2 to kna1-name2.
move ksadr-name3 to kna1-name3.
move ksadr-name4 to kna1-name4.
move ksadr-ort01 to kna1-ort01.
move ksadr-stras to kna1-stras.
move ksadr-regio to kna1-regio.
move ksadr-land1 to kna1-land1.
move ksadr-pstlz to kna1-pstlz.
move ksadr-telf1 to kna1-telf1.
move ksadr-telfx to kna1-telfx.
**start of changes $16
** select single smtp_addr from adr6 into ws_smtp_addr
** where addrnumber = vbpa-adrnr.
** if sy-subrc = 0.
** move ws_smtp_addr to adr6-smtp_addr.
** endif.
* call function 'addr_comm_get'
* exporting
* address_number = vbpa-adrnr
** date_from = '00010101'
* language = sy-langu
* table_type = 'adsmtp'
** importing
** returncode =
* tables
* comm_table = int_adr6
** error_table =
* exceptions
* parameter_error = 1
* address_not_exist = 2
* internal_error = 3
* others = 4
* .
* if sy-subrc <> 0.
* endif.
** endif.
* read table int_adr6 index 1.
* move int_adr6-smtp_addr to adr6-smtp_addr.
**end of changes
*started the changes $16
select *
from vbpa
into corresponding fields of table t_vbpa10
where vbeln = vbak-vbeln
and parvw = 'ag'.

if not t_vbpa10[] is initial.


*to check the filed flagcomm6 from the adrc table by passing the adrnumber from
the vbpa table.
select addrnumber flagcomm6
from adrc
into corresponding fields of table it_tab3
for all entries in t_vbpa10
where addrnumber = t_vbpa10-adrnr
and flagcomm6 = 'x'.
if sy-subrc = 0.
* if sy-sybrc is true get the smtp_addr from the adr6 by passing the addrnumber
and persunmber as space.
select smtp_addr
from adr6
into table it_adr6
for all entries in t_vbpa10
where addrnumber = t_vbpa10-adrnr
and persnumber = space.

else.
*if sy-subrc is false then get the adrnr and parnr from vbpa by passing th vbeln
and parvw.
select adrnr parnr
from vbpa
into corresponding fields of table t_vbpa2
where vbeln = vbak-vbeln
and parvw = 'ap'.

if not t_vbpa2[] is initial.


select prsnr
from knvk
into corresponding fields of table t_knvk
for all entries in t_vbpa2
where parnr = t_vbpa2-parnr.
* endif.

select *
from adr6
into corresponding fields of table t_adr6
for all entries in t_vbpa2
where addrnumber = t_vbpa2-adrnr.
endif.
if not t_adr6[] is initial.
select *
from adr6
into corresponding fields of table t_adr61
for all entries in t_knvk
where persnumber = t_knvk-prsnr.

endif.
loop at t_adr6.
read table t_adr61 with key addrnumber = t_adr6-addrnumber persnumber
= t_adr6-persnumber.
if sy-subrc <> 0.
delete t_adr6.
endif.
move t_adr6-smtp_addr to adr6-smtp_addr.
endloop.
*if we look for the e-mail address for the ship-to, the program only
*needs to access adr6 with the address number of the ship-to from the
*order.
select adrnr
from vbpa
into corresponding fields of table it_vbpa002
where vbeln = vbak-vbeln
and parvw = 'we'.
if not it_vbpa002[] is initial.
select smtp_addr
from adr6
into corresponding fields of table it_adr6
for all entries in it_vbpa002
where addrnumber = it_vbpa002-adrnr
and persnumber = space.

endif.
endif.
loop at it_adr6.
* read table it_adr6 with key addrnumber = it_vbpa002-adrnr.
* if sy-subrc <> 0.
* delete it_adr6.
* endif.
move it_adr6-smtp_addr to adr6-smtp_addr.
endloop.

endif.
* end of changes "$16
endif.
endif.

refresh ktab2.
* refresh ksadr.
select *
from vbpa
into table vbpa1
where vbeln = vbak-vbeln
and posnr = '000000' "$14
and parvw = 'ap'.
sy-subrc = 4. "$2
if sy-subrc <> 0.
select *
from vbpa
into table vbpa1
where vbeln = vbak-vbeln
and posnr = '000000' "$14
and parvw = 'we'.

if sy-subrc <> 0.
select * from kna1 into table ktab2
where kunnr = vbak-kunnr.
loop at ktab2.
move ktab2-name1 to name1.
move ktab2-name2 to name2.
move ktab2-name3 to name3.
move ktab2-name4 to name4.
move ktab2-ort01 to ort01.
move ktab2-regio to regio.
move ktab2-land1 to w_land1.
move ktab2-pstlz to pstlz.
endloop.
else.
* refresh ksadr.
loop at vbpa1.
perform get_sadr_address using vbpa1-adrnr.
* select * from sadr into table ksadr
* where adrnr = vbpa1-adrnr.
endloop.
if vbpa1-adrnr is initial.
select * from kna1 into table ktab2
where kunnr = vbak-kunnr.
loop at ktab2.
move ktab2-name1 to name1.
move ktab2-name2 to name2.
move ktab2-name3 to name3.
move ktab2-name4 to name4.
move ktab2-ort01 to ort01.
move ktab2-stras to stras.
move ktab2-regio to regio.
move ktab2-land1 to land.
move ktab2-pstlz to pstlz.
endloop.

else.
* loop at ksadr.
move ksadr-name1 to name1.
move ksadr-name2 to name2.
move ksadr-name3 to name3.
move ksadr-name4 to name4.
move ksadr-ort01 to ort01.
move ksadr-stras to stras.
move ksadr-regio to regio.
move ksadr-land1 to land.
move ksadr-pstlz to pstlz.
* endloop.
endif.
* start of insertion "$16
***********************************************************
** it will write the email-id if the flagcomm6 = yes
**********************************************************
* call function 'addr_comm_get'
* exporting
* address_number = vbpa1-adrnr
** date_from = '00010101'
* language = sy-langu
* table_type = 'adsmtp'
** importing
** returncode =
* tables
* comm_table = int_adr6
* exceptions
* parameter_error = 1
* address_not_exist = 2
* internal_error = 3
* others = 4
* .
* if sy-subrc <> 0.
* endif.
* read table int_adr6 index 1.
* move int_adr6-smtp_addr to adr6-smtp_addr.
* end of insertion "$16
* start of changes "$16
select *
from vbpa
into corresponding fields of table t_vbpa10
where vbeln = vbak-vbeln
and parvw = 'ag'.

if not t_vbpa10[] is initial.


*to check the filed flagcomm6 from the adrc table by passing the adrnumber from
the vbpa table.
select addrnumber flagcomm6
from adrc
into corresponding fields of table it_tab3
for all entries in t_vbpa10
where addrnumber = t_vbpa10-adrnr
and flagcomm6 = 'x'.
if sy-subrc = 0.
* if sy-sybrc is true get the smtp_addr from the adr6 by passing the addrnumber
and persunmber as space.
select smtp_addr
from adr6
into table it_adr6
for all entries in t_vbpa10
where addrnumber = t_vbpa10-adrnr
and persnumber = space.

else.
*if sy-subrc is false then get the adrnr and parnr from vbpa by passing th vbeln
and parvw.
select adrnr parnr
from vbpa
into corresponding fields of table t_vbpa2
where vbeln = vbak-vbeln
and parvw = 'ap'.

if not t_vbpa2[] is initial.


select prsnr
from knvk
into corresponding fields of table t_knvk
for all entries in t_vbpa2
where parnr = t_vbpa2-parnr.
* endif.

select *
from adr6
into corresponding fields of table t_adr6
for all entries in t_vbpa2
where addrnumber = t_vbpa2-adrnr.
endif.
if not t_adr6[] is initial.
select *
from adr6
into corresponding fields of table t_adr61
for all entries in t_knvk
where persnumber = t_knvk-prsnr.

endif.
loop at t_adr6.
read table t_adr61 with key addrnumber = t_adr6-addrnumber persnumber
= t_adr6-persnumber.
if sy-subrc <> 0.
delete t_adr6.
endif.
move t_adr6-smtp_addr to adr6-smtp_addr.
endloop.
*if we look for the e-mail address for the ship-to, the program only
*needs to access adr6 with the address number of the ship-to from the
*order.
select adrnr
from vbpa
into corresponding fields of table it_vbpa002
where vbeln = vbak-vbeln
and parvw = 'we'.
if not it_vbpa002[] is initial.
select smtp_addr
from adr6
into corresponding fields of table it_adr6
for all entries in it_vbpa002
where addrnumber = it_vbpa002-adrnr
and persnumber = space.

endif.
endif.
loop at it_adr6.
* read table it_adr6 with key addrnumber = it_vbpa002-adrnr.
* if sy-subrc <> 0.
* delete it_adr6.
* endif.
move it_adr6-smtp_addr to adr6-smtp_addr.
endloop.

endif.
* end of changes "$16
endif.
else.
perform contact_person_address.
endif.
if w_zqueid is initial and
w_zcland is initial.
select *
from zvs13
into table int_zvs13
where vbeln = vbak-vbeln
and stonr <> 40
and stonr <> 50.
elseif not w_zqueid is initial.
select *
from zvs13
into table int_zvs13
where vbeln = vbak-vbeln
and stonr <> 40
and stonr <> 50
and zqueid = w_zqueid.
elseif not w_zcland is initial.
select *
from zvs13
into table int_zvs13
where vbeln = vbak-vbeln
and stonr <> 40
and stonr <> 50
and ( zcland = w_zcland ).
endif.
refresh int_del.
select *
from zvs13
into table int_del
where stonr = 50
and laeda = sy-datum.
top_line = 1.
endform. "record_change
*eject
*&---------------------------------------------------------------------*
*& module user_command_0700 input
*----------------------------------------------------------------------*
module user_command_0700 input.

if sy-ucomm = 'push' or
sy-ucomm = 'canc'.
set screen 0.
leave screen.
endif.
endmodule. " user_command_0700 input
*eject
*&---------------------------------------------------------------------*
*& module status_0700 output
*&---------------------------------------------------------------------*
module status_0700 output.
set pf-status 'z700'.
set titlebar 'zpus'.

endmodule. " status_0700 output


*&---------------------------------------------------------------------*
*& form exit
*&---------------------------------------------------------------------*
* the line item or the order in zvs50 should be deleted.
*----------------------------------------------------------------------*
form exit.

clear ok_code300.
if *zvs50-vbeln = int_zvs13-vbeln.
delete *zvs50 where vbeln = int_zvs13-vbeln and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = int_zvs13-vbeln and ernam = sy-uname.
endif.

if *zvs50-vbeln = vbak-vbeln.
delete *zvs50 where vbeln = vbak-vbeln and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = vbak-vbeln and ernam = sy-uname.
endif.
loop at *zvs50.
if *zvs50-vbeln = chk_tab-vbeln.
delete *zvs50 where vbeln = chk_tab-vbeln and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = chk_tab-vbeln and ernam = sy-uname.
if sy-subrc = 0.
describe table chk_tab lines lin_no.
if num1 < lin_no.
num1 = num1 + 1.
if num1 > 1.
endif.
read table chk_tab index num1.
endif.
endif.
endif.
endloop.
endform. " exit
*&---------------------------------------------------------------------*
*& form back
*&---------------------------------------------------------------------*
* the line item or the order in zvs50 should be deleted *
*-----------------------------------------------------------------------
form back.
if *zvs50-vbeln = int_zvs13-vbeln.
delete *zvs50 where vbeln = int_zvs13-vbeln and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = int_zvs13-vbeln and ernam = sy-uname.
endif.
if *zvs50-vbeln = vbak-vbeln.
delete *zvs50 where vbeln = vbak-vbeln and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = vbak-vbeln and ernam = sy-uname.
endif.
loop at *zvs50.
if *zvs50-vbeln = chk_tab-vbeln.
delete *zvs50 where vbeln = chk_tab-vbeln and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = chk_tab-vbeln and ernam = sy-uname.
if sy-subrc = 0.
describe table chk_tab lines lin_no.
if num1 < lin_no.
num1 = num1 + 1.
if num1 > 1.
endif.
read table chk_tab index num1.
endif.
endif.
endif.
endloop.
describe table itab lines lin_no.
if lin_no = 0.
set screen 100. leave screen.
endif.
endform. " back
*&---------------------------------------------------------------------*
*& form canc
*&---------------------------------------------------------------------*
* the line item or the order in zvs50 should be deleted *
*----------------------------------------------------------------------*

form canc.

if *zvs50-vbeln = int_zvs13-vbeln.
delete *zvs50 where vbeln = int_zvs13-vbeln and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = int_zvs13-vbeln and ernam = sy-uname.
endif.

if *zvs50-vbeln = vbak-vbeln.
delete *zvs50 where vbeln = vbak-vbeln and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = vbak-vbeln and ernam = sy-uname.
endif.
loop at *zvs50.
if *zvs50-vbeln = chk_tab-vbeln.
delete *zvs50 where vbeln = chk_tab-vbeln and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = chk_tab-vbeln and ernam = sy-uname.
if sy-subrc = 0.
describe table chk_tab lines lin_no.
if num1 < lin_no.
num1 = num1 + 1.
if num1 > 1.
endif.
read table chk_tab index num1.
endif.
endif.
endif.
endloop.
endform. " canc
*&---------------------------------------------------------------------*
*& form comt
*&---------------------------------------------------------------------*
* for the line item selected - description
*----------------------------------------------------------------------*
form comment.
refresh ck_tab.
clear ck_tab.
loop at int_zvs13.
if int_zvs13-checkbox = 'x'.
move-corresponding int_zvs13 to ck_tab.
append ck_tab.
endif.
endloop.

numr = 1.
read table ck_tab index numr.
clear ok_code300.
* move 'disp' to ws_process_mode.
* export ws_process_mode to memory id 'zvs06scr_process_mode'.
* select single bismt matkl into (zvs06-bismt, zvs06-matkl)
* from mara where matnr eq ck_tab-matnr.
* if sy-subrc eq 0.
* set parameter id 'zbl' field zvs06-bismt.
* set parameter id 'mkl' field zvs06-matkl.
* export ws_process_mode to memory id 'zvs06scr_process_mode'.
* call transaction 'zcom' and skip first screen.
* endif.
set screen 400.
leave screen.
endform. " comment
*&---------------------------------------------------------------------*
*& form secu
*&---------------------------------------------------------------------*
form secu_delay.

loop at int_zvs13.
move ' ' to int_zvs13-checkbox.
modify int_zvs13.
move int_zvs13-checkbox to citab-checkbox.
append citab.
endloop.
set screen 300.
leave screen.
endform. " secu_delay
*&---------------------------------------------------------------------*
*& form else
*&---------------------------------------------------------------------*
* security to be deleted in zvs50.
*----------------------------------------------------------------------*
form else.

delete int_zvs13 where checkbox = 'x'.


describe table int_zvs13 lines lin_no.
if lin_no <> 0.
set screen 300. leave screen.
elseif chk_tab-chekbox = 'x'.
describe table chk_tab lines lin_no.
if num1 < lin_no.
num1 = num1 + 1.
if num1 > 1.
endif.

if *zvs50-vbeln = int_zvs13-vbeln.
delete *zvs50 where vbeln = int_zvs13-vbeln
and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = int_zvs13-vbeln
and ernam = sy-uname.
endif.

loop at *zvs50.
if *zvs50-vbeln = chk_tab-vbeln.
delete *zvs50 where vbeln = chk_tab-vbeln and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = chk_tab-vbeln and ernam = sy-uname.
endif.
endloop.
read table chk_tab index num1.
set screen 300. leave screen.
else.
if *zvs50-vbeln = int_zvs13-vbeln.
delete *zvs50 where vbeln = int_zvs13-vbeln
and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = int_zvs13-vbeln
and ernam = sy-uname.
endif.

loop at *zvs50.
if *zvs50-vbeln = chk_tab-vbeln.
delete *zvs50 where vbeln = chk_tab-vbeln and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = chk_tab-vbeln and ernam = sy-uname.
endif.
endloop.
set screen 200. leave screen.
endif.
else.

if *zvs50-vbeln = int_zvs13-vbeln.
delete *zvs50 where vbeln = int_zvs13-vbeln
and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = int_zvs13-vbeln
and ernam = sy-uname.
endif.

loop at *zvs50.
if *zvs50-vbeln = chk_tab-vbeln.
delete *zvs50 where vbeln = chk_tab-vbeln and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = chk_tab-vbeln and ernam = sy-uname.
endif.
endloop.
set screen 200. leave screen.
endif.
endform. " else
*&---------------------------------------------------------------------*
*& form mian
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
* selection of the next item and deleting the record in table zvs50.
* security of zvs50 *
*&---------------------------------------------------------------------*
form mian.

delete int_zvs13 where checkbox = 'x'.


describe table int_zvs13 lines lin_no.
if lin_no <> 0.
set screen 300. leave screen.
elseif chk_tab-chekbox = 'x'.
describe table chk_tab lines lin_no.
if num1 < lin_no.
num1 = num1 + 1.
if num1 > 1.
endif.

if *zvs50-vbeln = int_zvs13-vbeln.
delete *zvs50 where vbeln = int_zvs13-vbeln
and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = int_zvs13-vbeln
and ernam = sy-uname.
endif.

loop at *zvs50.
if *zvs50-vbeln = chk_tab-vbeln.
delete *zvs50 where vbeln = chk_tab-vbeln and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = chk_tab-vbeln and ernam = sy-uname.
endif.
endloop.
read table chk_tab index num1.
set screen 300. leave screen.
else.
if *zvs50-vbeln = int_zvs13-vbeln.
delete *zvs50 where vbeln = int_zvs13-vbeln
and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = int_zvs13-vbeln
and ernam = sy-uname.
endif.

loop at *zvs50.
if *zvs50-vbeln = chk_tab-vbeln.
delete *zvs50 where vbeln = chk_tab-vbeln and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = chk_tab-vbeln and ernam = sy-uname.
endif.
endloop.
set screen 200. leave screen.
endif.
else.

if *zvs50-vbeln = int_zvs13-vbeln.
delete *zvs50 where vbeln = int_zvs13-vbeln
and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = int_zvs13-vbeln
and ernam = sy-uname.
endif.
loop at *zvs50.
if *zvs50-vbeln = chk_tab-vbeln.
delete *zvs50 where vbeln = chk_tab-vbeln and ernam = sy-uname.
clear *zvs50.
delete from zvs50 where vbeln = chk_tab-vbeln and ernam = sy-uname.
endif.
endloop.
set screen 200. leave screen.
endif.
endform. " mian
*&---------------------------------------------------------------------*
*& form top_part_of_screen
*&---------------------------------------------------------------------*
* if you directly come from filter screen when you enter the sales
* document then this is for sold to, ship to, contact person address.
*----------------------------------------------------------------------*
form top_part_of_screen.

if zvs13-vbeln is initial.
else.
vbak-vbeln = zvs13-vbeln.
endif.

if vbak-vbeln < c_purchase_requisition_high and "$3


" purchase requisition
vbak-vbeln >= c_purchase_requisition_low. "$3
refresh itvtab.
if sy-ucomm = 'yes'. " released order
select *
from zvs13
into table itvtab
where vbeln = vbak-vbeln.
else.
select *
from zvs13
into table itvtab
where vbeln = vbak-vbeln
and stonr <> 40.
endif.

loop at itvtab.
move itvtab-zshipno to vbak-kunnr.
move itvtab-kunnr to kna1-kunnr.
endloop.
else. "$3
select * "$3
from vbpa "$3
into corresponding fields of table t_vbpa "$3
where vbeln = vbak-vbeln "$3
and posnr = '000000'. "$3

loop at t_vbpa. "$3


if t_vbpa-parvw = 'ag'. "$3
move t_vbpa-kunnr to kna1-kunnr. "$3
elseif t_vbpa-parvw = 'we'. "$3
move t_vbpa-kunnr to vbak-kunnr. "$3
endif. "$3
endloop. "$3
endif. "$3

refresh ktab.
clear kna1-name1.
clear kna1-name2.
clear kna1-name3.
clear kna1-name4.
clear kna1-ort01.
clear kna1-stras.
clear kna1-regio.
clear kna1-land1.
clear kna1-pstlz.
clear kna1-telf1.
clear kna1-telfx.
clear adr6-smtp_addr.

refresh ktab1.
clear name1.
clear name2.
clear name3.
clear name4.
clear ort01.
clear stras.
clear regio.
clear land.
clear pstlz.
clear telf1.
clear telfx.
clear smtp_addr.

if vbak-vbeln < c_purchase_requisition_high and " purchase requisition


vbak-vbeln >= c_purchase_requisition_low.
perform top_part_of_screen_po.
exit.
endif.

select single * from vbkd where vbeln = vbak-vbeln


and posnr = 000000.

move 'sales doc' to doc_type.


move 'sold to' to sold_to.
* move 'ship to/contact person' to ship_to. "$2
move 'ship to' to ship_to. "$2

select * from kna1 into table ktab


where kunnr = kna1-kunnr.
if sy-subrc = 0.
loop at ktab.
move ktab-name1 to kna1-name1.
move ktab-name2 to kna1-name2.
move ktab-name3 to kna1-name3.
move ktab-name4 to kna1-name4.
move ktab-ort01 to kna1-ort01.
move ktab-stras to kna1-stras.
move ktab-regio to kna1-regio.
move ktab-land1 to kna1-land1.
move ktab-pstlz to kna1-pstlz.
move ktab-telf1 to kna1-telf1.
move ktab-telfx to kna1-telfx.
endloop.
else.
clear ktab.
endif.

select single * from vbpa where vbeln = vbak-vbeln


and posnr = 000000
and parvw = 'ag'.

if sy-subrc = 0.
if vbpa-adrda = 'e'. " manual address
perform get_sadr_address using vbpa-adrnr.
move ksadr-name1 to kna1-name1.
move ksadr-name2 to kna1-name2.
move ksadr-name3 to kna1-name3.
move ksadr-name4 to kna1-name4.
move ksadr-ort01 to kna1-ort01.
move ksadr-stras to kna1-stras.
move ksadr-regio to kna1-regio.
move ksadr-land1 to kna1-land1.
move ksadr-pstlz to kna1-pstlz.
move ksadr-telf1 to kna1-telf1.
move ksadr-telfx to kna1-telfx.
*started the changes dsekhar
* select single smtp_addr from adr6 into ws_smtp_addr
* where addrnumber = vbpa-adrnr.
*
* if sy-subrc = 0.
* move ws_smtp_addr to adr6-smtp_addr.
* endif.
* call function 'addr_comm_get'
* exporting
* address_number = vbpa1-adrnr
* language = sy-langu
* table_type = 'adsmtp'
** importing
** returncode =
* tables
* comm_table = int_adr6
* exceptions
* parameter_error = 1
* address_not_exist = 2
* internal_error = 3
* others = 4
* .
* if sy-subrc <> 0.
* endif.
* read table int_adr6 index 1.
* move int_adr6-smtp_addr to adr6-smtp_addr.
** end of changes
select *
from vbpa
into corresponding fields of table t_vbpa10
where vbeln = vbak-vbeln
and parvw = 'ag'.

if not t_vbpa10[] is initial.


*to check the filed flagcomm6 from the adrc table by passing the adrnumber from
the vbpa table.
select addrnumber flagcomm6
from adrc
into corresponding fields of table it_tab3
for all entries in t_vbpa10
where addrnumber = t_vbpa10-adrnr
and flagcomm6 = 'x'.
if sy-subrc = 0.
* if sy-sybrc is true get the smtp_addr from the adr6 by passing the addrnumber
and persunmber as space.
select smtp_addr
from adr6
into table it_adr6
for all entries in t_vbpa10
where addrnumber = t_vbpa10-adrnr
and persnumber = space.

else.
*if sy-subrc is false then get the adrnr and parnr from vbpa by passing th vbeln
and parvw.
select adrnr parnr
from vbpa
into corresponding fields of table t_vbpa2
where vbeln = vbak-vbeln
and parvw = 'ap'.

if not t_vbpa2[] is initial.


select prsnr
from knvk
into corresponding fields of table t_knvk
for all entries in t_vbpa2
where parnr = t_vbpa2-parnr.
* endif.

select *
from adr6
into corresponding fields of table t_adr6
for all entries in t_vbpa2
where addrnumber = t_vbpa2-adrnr.
endif.
if not t_adr6[] is initial.
select *
from adr6
into corresponding fields of table t_adr61
for all entries in t_knvk
where persnumber = t_knvk-prsnr.

endif.
loop at t_adr6.
read table t_adr61 with key addrnumber = t_adr6-addrnumber persnumber
= t_adr6-persnumber.
if sy-subrc <> 0.
delete t_adr6.
endif.
move t_adr6-smtp_addr to adr6-smtp_addr.
endloop.
*if we look for the e-mail address for the ship-to, the program only
*needs to access adr6 with the address number of the ship-to from the
*order.
select adrnr
from vbpa
into corresponding fields of table it_vbpa002
where vbeln = vbak-vbeln
and parvw = 'we'.
if not it_vbpa002[] is initial.
select smtp_addr
from adr6
into corresponding fields of table it_adr6
for all entries in it_vbpa002
where addrnumber = it_vbpa002-adrnr
and persnumber = space.

endif.
endif.
loop at it_adr6.
* read table it_adr6 with key addrnumber = it_vbpa002-adrnr.
* if sy-subrc <> 0.
* delete it_adr6.
* endif.
move it_adr6-smtp_addr to adr6-smtp_addr.
endloop.

endif.
* end of changes "$16
endif.
endif.

select *
from vbpa
into table vbpa1
where vbeln = vbak-vbeln
and posnr = '000000' "$14
and parvw = 'ap'.

* select single prsnr


* from knvk
* into w_prsnr
* where parnr = vbpa1-pernr.
sy-subrc = 4. "$2
if sy-subrc <> 0.
select *
from vbpa
into table vbpa1
where vbeln = vbak-vbeln
and posnr = '000000' "$14
and parvw = 'we'.

if sy-subrc <> 0.
select * from kna1 into table ktab1
where kunnr = vbak-kunnr.
loop at ktab1.
move ktab1-name1 to name1.
move ktab1-name2 to name2.
move ktab1-name3 to name3.
move ktab1-name4 to name4.
move ktab1-ort01 to ort01.
move ktab1-regio to regio.
move ktab1-land1 to w_land1.
move ktab1-pstlz to pstlz.
move ktab1-telf1 to telf1.
move ktab1-telfx to telfx.
endloop.
else.
* refresh ksadr.
loop at vbpa1.
perform get_sadr_address using vbpa1-adrnr.
* select * from sadr into table ksadr
* where adrnr = vbpa1-adrnr.
endloop.
if vbpa1-adrnr is initial.
select * from kna1 into table ktab1
where kunnr = vbak-kunnr.

loop at ktab1.
move ktab1-name1 to name1.
move ktab1-name2 to name2.
move ktab1-name3 to name3.
move ktab1-name4 to name4.
move ktab1-ort01 to ort01.
move ktab1-stras to stras.
move ktab1-regio to regio.
move ktab1-land1 to land.
move ktab1-pstlz to pstlz.
move ktab1-telf1 to telf1.
move ktab1-telfx to telfx.
endloop.
else.
* loop at ksadr.
move ksadr-name1 to name1.
move ksadr-name2 to name2.
move ksadr-name3 to name3.
move ksadr-name4 to name4.
move ksadr-ort01 to ort01.
move ksadr-stras to stras.
move ksadr-regio to regio.
move ksadr-land1 to land.
move ksadr-pstlz to pstlz.
move ksadr-telf1 to telf1.
move ksadr-telfx to telfx.
* started the changes "$16
select *
from vbpa
into corresponding fields of table t_vbpa10
where vbeln = vbak-vbeln
and parvw = 'ag'.

if not t_vbpa10[] is initial.


*to check the filed flagcomm6 from the adrc table by passing the adrnumber from
the vbpa table.

select addrnumber flagcomm6


from adrc
into corresponding fields of table it_tab3
for all entries in t_vbpa10
where addrnumber = t_vbpa10-adrnr
and flagcomm6 = 'x'.
if sy-subrc = 0.
* if sy-sybrc is true get the smtp_addr from the adr6 by passing the addrnumber
and persunmber as space.
select smtp_addr
from adr6
into corresponding fields of table it_adr6
for all entries in t_vbpa10
where addrnumber = t_vbpa10-adrnr
and persnumber = space.

else.
*if sy-subrc is false then get the adrnr and parnr from vbpa by passing th vbeln
and parvw.

select adrnr parnr


from vbpa
into corresponding fields of table t_vbpa2
where vbeln = vbak-vbeln
and parvw = 'ap'.

if not t_vbpa2[] is initial.


select prsnr
from knvk
into corresponding fields of table t_knvk
for all entries in t_vbpa2
where parnr = t_vbpa2-parnr.
* endif.
*
select *
from adr6
into corresponding fields of table t_adr6
for all entries in t_vbpa2
where
addrnumber = t_vbpa2-adrnr.
endif.
if not t_adr6[] is initial.
select *
from adr6
into corresponding fields of table t_adr61
for all entries in t_knvk
where persnumber = t_knvk-prsnr.

endif.
loop at t_adr6.
read table t_adr61 with key addrnumber = t_adr6-addrnumber
persnumber = t_adr6-persnumber.
if sy-subrc <> 0.
delete t_adr6.
endif.
move t_adr6-smtp_addr to adr6-smtp_addr.
endloop.
*if we look for the e-mail address for the ship-to, the program only
*needs to access adr6 with the address number of the ship-to from the
*order.
select adrnr
from vbpa
into corresponding fields of table it_vbpa002
where vbeln = vbak-vbeln
and parvw = 'we'.
if not it_vbpa002[] is initial.
select smtp_addr
from adr6
into corresponding fields of table it_adr6
for all entries in it_vbpa002
where addrnumber = it_vbpa002-adrnr
and persnumber = space.

endif.
endif.
loop at it_adr6.
* read table it_adr6 with key addrnumber = it_vbpa002-adrnr.
* if sy-subrc <> 0.
* delete it_adr6.
* endif.
move it_adr6-smtp_addr to adr6-smtp_addr.

endloop.
endif.
endif.
endif.
else.
perform contact_person_address.
endif.
endform. " top_part_of_screen
*&---------------------------------------------------------------------*
*& form top_part_of_screen_po
*&---------------------------------------------------------------------*
* this is for purchase requisition / purchase order to display
* vendor and receiving plant address.
*----------------------------------------------------------------------*
form top_part_of_screen_po.
move 'pr/po doc' to doc_type.
move 'vendor' to sold_to.
move 'rec plant' to ship_to.

select single * from t001w " read plant table


where werks = vbak-kunnr. " to get receiving plant address

if syst-subrc = 0.
move t001w-land1 to land. " country.
move t001w-name1 to name1.
move t001w-name2 to name2.
move t001w-stras to stras.
move t001w-ort01 to ort01.
move t001w-regio to regio.
move t001w-pstlz to pstlz.
endif.

select single * from lfa1 " read vendor master table


where lifnr = kna1-kunnr.

if sy-subrc = 0.
move lfa1-name1 to kna1-name1.
move lfa1-name2 to kna1-name2.
move lfa1-name3 to kna1-name3.
move lfa1-name4 to kna1-name4.
move lfa1-ort01 to kna1-ort01.
move lfa1-stras to kna1-stras.
move lfa1-regio to kna1-regio.
move lfa1-pstlz to kna1-pstlz.
move lfa1-land1 to kna1-land1.
endif.
endform. " top_part_of_screen_po

*&---------------------------------------------------------------------*
*& form header
*&---------------------------------------------------------------------*
form header.

move 'sales doc' to doc_type.


move 'sold to' to sold_to.
* move 'ship to/contact person' to ship_to. "$2
move 'ship to' to ship_to. "$2

clear kna1-name1.
clear kna1-name2.
clear kna1-name3.
clear kna1-name4.
clear kna1-ort01.
clear kna1-stras.
clear kna1-regio.
clear kna1-land1.
clear kna1-pstlz.
clear kna1-telf1.
clear kna1-telfx.
clear adr6-smtp_addr.
refresh ktab.

refresh ktab1.
clear name1.
clear name2.
clear name3.
clear name4.
clear ort01.
clear stras.
clear regio.
clear land.
clear pstlz.
clear telf1.
clear telfx.
clear smtp_addr.

if vbak-vbeln < c_purchase_requisition_high and " purchase requisition


vbak-vbeln >= c_purchase_requisition_low.
perform top_part_of_screen_po.
exit.
endif.

select single * from vbkd where vbeln = vbak-vbeln


and posnr = 000000.

select * from kna1 into table ktab


where kunnr = kna1-kunnr.
if sy-subrc = 0.
loop at ktab.
move ktab-name1 to kna1-name1.
move ktab-name2 to kna1-name2.
move ktab-name3 to kna1-name3.
move ktab-name4 to kna1-name4.
move ktab-ort01 to kna1-ort01.
move ktab-stras to kna1-stras.
move ktab-regio to kna1-regio.
move ktab-land1 to kna1-land1.
move ktab-pstlz to kna1-pstlz.
move ktab-telf1 to kna1-telf1.
move ktab-telfx to kna1-telfx.
endloop.
else.
clear ktab.
endif.

read table t_vbpa with key vbeln = vbak-vbeln


posnr = '000000'
parvw = 'ag'.
if sy-subrc = 0.
if vbpa-adrda = 'e'. " manual address
perform get_sadr_address using vbpa-adrnr.
move ksadr-name1 to kna1-name1.
move ksadr-name2 to kna1-name2.
move ksadr-name3 to kna1-name3.
move ksadr-name4 to kna1-name4.
move ksadr-ort01 to kna1-ort01.
move ksadr-stras to kna1-stras.
move ksadr-regio to kna1-regio.
move ksadr-land1 to kna1-land1.
move ksadr-pstlz to kna1-pstlz.
move ksadr-telf1 to kna1-telf1.
move ksadr-telfx to kna1-telfx.

select single smtp_addr from adr6 into ws_smtp_addr


where addrnumber = vbpa-adrnr.
if sy-subrc = 0.
move ws_smtp_addr to adr6-smtp_addr.
endif.
endif.
endif.

refresh ktab2.
* refresh ksadr.
select *
from vbpa
into table vbpa1
where vbeln = vbak-vbeln
and posnr = '000000' "$14
and parvw = 'ap'.

sy-subrc = 4. "$2
if sy-subrc <> 0 .
select *
from vbpa
into table vbpa1
where vbeln = vbak-vbeln
and posnr = '000000' "$14
and parvw = 'we'.

if sy-subrc <> 0.
select * from kna1 into table ktab2
where kunnr = vbak-kunnr.
loop at ktab2.
move ktab2-name1 to name1.
move ktab2-name2 to name2.
move ktab2-name3 to name3.
move ktab2-name4 to name4.
move ktab2-ort01 to ort01.
move ktab2-regio to regio.
move ktab2-land1 to w_land1.
move ktab2-pstlz to pstlz.
move ktab2-telf1 to telf1.
move ktab2-telfx to telfx.
endloop.
else.
* refresh ksadr.
loop at vbpa1.
perform get_sadr_address using vbpa1-adrnr.
* select * from sadr into table ksadr
* where adrnr = vbpa1-adrnr.
endloop.
if vbpa1-adrnr is initial.
select * from kna1 into table ktab2
where kunnr = vbak-kunnr.
loop at ktab2.
move ktab2-name1 to name1.
move ktab2-name2 to name2.
move ktab2-name3 to name3.
move ktab2-name4 to name4.
move ktab2-ort01 to ort01.
move ktab2-stras to stras.
move ktab2-regio to regio.
move ktab2-land1 to land.
move ktab2-pstlz to pstlz.
move ktab2-telf1 to telf1.
move ktab2-telfx to telfx.
endloop.

else.
* loop at ksadr.
move ksadr-name1 to name1.
move ksadr-name2 to name2.
move ksadr-name3 to name3.
move ksadr-name4 to name4.
move ksadr-ort01 to ort01.
move ksadr-stras to stras.
move ksadr-regio to regio.
move ksadr-land1 to land.
move ksadr-pstlz to pstlz.
move ksadr-telf1 to telf1.
move ksadr-telfx to telfx.
select single smtp_addr from adr6 into smtp_addr
where addrnumber = vbpa1-adrnr.

* endloop.
endif.
endif.
else.
perform contact_person_address.
endif.
endform. " header
*&---------------------------------------------------------------------*
*& form bottom_screen
*&---------------------------------------------------------------------*
form bottom_screen.
if w_zqueid is initial
and w_zcland is initial.
select *
from zvs13
into table int_zvs13
where vbeln = vbak-vbeln
and stonr <> 40
and stonr <> 50.
elseif not w_zcland is initial.
if w_zqueid is initial.
select *
from zvs13
into table int_zvs13
where vbeln = vbak-vbeln
and stonr <> 40
and stonr <> 50
and zcland = w_zcland.
else.
select *
from zvs13
into table int_zvs13
where vbeln = vbak-vbeln
and stonr <> 40
and stonr <> 50
and zcland = w_zcland
and zqueid = w_zqueid.
endif.
elseif not w_zqueid is initial.
select *
from zvs13
into table int_zvs13
where vbeln = vbak-vbeln
and stonr <> 40
and stonr <> 50
and zqueid = w_zqueid.
endif.
describe table int_zvs13 lines lin_no.
loop at int_zvs13.
if exclude_delayed = 'x'.
if int_zvs13-zohind = 'x'.
if int_zvs13-zohdat > sy-datum.
delete int_zvs13 where zohdat > sy-datum.
elseif int_zvs13-zohdat = sy-datum and
int_zvs13-zohtim > sy-uzeit.
delete int_zvs13 where zohtim > sy-uzeit.
exit.
endif.
endif.
endif.
if only_delayed = 'x'.
if int_zvs13-zohdat < sy-datum.
delete int_zvs13 where zohdat < sy-datum.
elseif int_zvs13-zohdat = sy-datum
and int_zvs13-zohtim < sy-uzeit.
delete int_zvs13 where zohtim < sy-uzeit.
exit.
endif.
endif.
endloop.
endform. " bottom_screen
*eject
*&---------------------------------------------------------------------*
*& module status_0800 output
*&---------------------------------------------------------------------*
module status_0800 output.
set pf-status 'zrele'.
set titlebar 'zrel'.
endmodule. " status_0800 output
*&---------------------------------------------------------------------*
*& module user_command_0800 input
*&---------------------------------------------------------------------*
module user_command_0800 input.
case : rel_code.
when 'back'.
if rcode = 'y'.
set screen 100.
leave screen.
else.
set screen 300. leave screen.
endif.

when 'canc'.
if rcode = 'y'.
set screen 100. leave screen.
else.
set screen 300.
leave screen.
endif.

when 'exit'.
if rcode = 'y'.
set screen 100. leave screen.
else.
set screen 300.
leave screen.
endif.

when 'frst'.
perform paging_release using 'frst'.
when 'prev'.
perform paging_release using 'prev'.
when 'next'.
perform paging_release using 'next'.
when 'last'.
perform paging_release using 'last'.
when 'sele'.
perform release_mark_all.

when 'dese'.
perform release_delete_all_marks.
clear ok_code300.

when 'comm'.
perform release_comment.

when 'disp'.
perform display.

when 'chan'.
perform change.
endcase.
endmodule. " user_command_0800 input
*&---------------------------------------------------------------------*
*& module display_released_order_item output
*&---------------------------------------------------------------------*
module display_released_order_item output.
select netpr from vbap into int_release-netpr
where vbeln = int_release-vbeln and
posnr = int_release-posnr.
vbap-netpr = int_release-netpr.
endselect.
select kwmeng from vbap into int_release-kwmeng
where vbeln = int_release-vbeln and
posnr = int_release-posnr .
vbap-kwmeng = int_release-kwmeng.
endselect.
select * from vbep where vbeln = int_release-vbeln and
posnr = int_release-posnr.
if int_release-kwmeng > vbep-bmeng.
move 'x' to bmeng.
endif.
endselect.

vbak-vbeln = int_release-vbeln.
zvs13-matnr = int_release-matnr.
zvs13-zcomtyp = int_release-zcomtyp.
zvs13-zlictyp = int_release-zlictyp.
zvs13-route = int_release-route.
zvs13-posnr = int_release-posnr.
zvs13-zqueid = int_release-zqueid.
zvs13-erdat = int_release-erdat.
zvs13-zseqno = int_release-zseqno.
zvs14t-zcomrea = int_release-zcomrea.
zvs13-name1_gp = int_release-name1_gp.
zvs13-zabdat = int_release-zabdat.
zvs13-zabtim = int_release-zabtim.
zvs13-ernam = int_release-ernam.
zvs13-erdat = int_release-erdat.
zvs13-erzeit = int_release-erzeit.
zvs13-aenam = int_release-aenam.
zvs13-laeda = int_release-laeda.
zvs13-lauhr = int_release-lauhr.
checkbox = citab-checkbox.
checkbox = int_release-checkbox.
select zcrdes from zvs14t into compliance_description where
zcomrea = int_release-zcomrea.
zvs14t-zcrdes = compliance_description.
endselect.

if int_release-stonr = '40'.
move 'scok' to stonr.
endif.
if int_release-stonr = '50'.
move 'scrj' to stonr.
endif.
endmodule. " display_released_order_item output
*&---------------------------------------------------------------------*
*& module display_released_order_header output
*&---------------------------------------------------------------------*
module display_released_order_header output.
if sy-ucomm = 'yes'.
perform top_part_of_screen.
endif.
endmodule. " display_released_order_header output
*&---------------------------------------------------------------------*
*& form paging_release
*&---------------------------------------------------------------------*
form paging_release using ccode.
data: linno type i,
i type i.
describe table int_release lines linno.
case ccode.
when 'frst'. top_line = 1.

when 'prev'.
top_line = top_line - line_count.
if top_line = 0.
top_line = 1.
endif.

when 'next'.
i = top_line + line_count.
linno = linno - line_count + 1.
if linno le 0.
linno = 1.
endif.
if i le linno.
top_line = i.
else.
top_line = linno.
endif.

when 'last'.
top_line = linno - line_count + 1.
if top_line le 0.
top_line = 1.
endif.
endcase.
endform. " paging_release
*&---------------------------------------------------------------------*
*& form release_mark_all
*&---------------------------------------------------------------------*
form release_mark_all.
refresh citab.
loop at int_release.
move 'x' to int_release-checkbox.
modify int_release.
move int_release-checkbox to citab-checkbox.
append citab.
endloop.
endform. " release_mark_all
*&---------------------------------------------------------------------*
*& form release_delete_all_marks
*&---------------------------------------------------------------------*
form release_delete_all_marks.

loop at int_release.
move ' ' to int_release-checkbox.
modify int_release.
move int_release-checkbox to citab-checkbox.
append citab.
endloop.
endform. " release_delete_all_marks
*&---------------------------------------------------------------------*
*& form release_comment
*&---------------------------------------------------------------------*
form release_comment.
refresh ck_tab.
clear ck_tab.
loop at int_release.
if int_release-checkbox = 'x'.
move-corresponding int_release to ck_tab.
append ck_tab.
endif.
endloop.

numr = 1.
read table ck_tab index numr.
move 'h' to fcode.
clear ok_code300.
set screen 400.
leave screen.
endform. " release_comment
*&---------------------------------------------------------------------*
*& form scr_400_back
*&---------------------------------------------------------------------*
form scr_400_back.
loop at int_zvs13.
move ' ' to int_zvs13-checkbox.
modify int_zvs13.
move int_zvs13-checkbox to citab-checkbox.
append citab.
endloop.
set screen 300.
leave screen.
endform. " scr_400_back
*&---------------------------------------------------------------------*
*& form release_scr_400_back
*&---------------------------------------------------------------------*
form release_scr_400_back.
loop at int_release.
move ' ' to int_release-checkbox.
modify int_release.
move int_release-checkbox to citab-checkbox.
append citab.
endloop.
set screen 800.
leave screen.
endform. " release_scr_400_back
*&---------------------------------------------------------------------*
*& module release_select_check input
*&---------------------------------------------------------------------*
module release_select_check input.
bas = sy-loopc + 1.
describe table int_release lines linno.
num = bas - sy-loopc + top_line - 1.
if checkbox = 'x'.
move 'x' to int_release-checkbox.
modify int_release index num.
else.
move ' ' to int_release-checkbox.
modify int_release index num.
endif.
endmodule. " release_select_check input
*&---------------------------------------------------------------------*
*& form scr_400_exit
*&---------------------------------------------------------------------*
form scr_400_exit.
loop at int_zvs13.
move ' ' to int_zvs13-checkbox.
modify int_zvs13.
move int_zvs13-checkbox to citab-checkbox.
append citab.
endloop.
clear ok_code400.
set screen 300.
leave screen.
endform. " scr_400_exit
*&---------------------------------------------------------------------*
*& form released_order_next
*&---------------------------------------------------------------------*
form released_order_next using next.
describe table ck_tab lines lin_no.
* case ccode.
* describe table ck_tab lines lin_no.
if numr < lin_no.
numr = numr + 1.
if numr > 1.
endif.
read table ck_tab index numr.
else.
loop at int_release.
move ' ' to int_release-checkbox.
modify int_release.
move int_release-checkbox to citab-checkbox.
append citab.
endloop.
set screen 800. leave screen.
endif.
* endcase.
endform. " released_order_next
*&---------------------------------------------------------------------*
*& form selection_order_status
*&---------------------------------------------------------------------*
form selection_order_status.

select *
from zvs13
into table indu
where vbeln = zvs13-vbeln
and stonr <> 20
and stonr <> 30.
loop at indu.
endloop.
if indu-vbeln <> ' '.
select * from zvs24t
where zpopup = 'queuerel'
and spras = sy-langu.
endselect.
if sy-subrc = 0.
move zvs24t-zpopdes to popup_text1.
move zvs24t-zpopdes+35(35) to popup_text2.
else.
move 'all items have been released from ' to popup_text1.
move 'the queue. view released items ? ' to popup_text2.
endif.

call function 'popup_to_confirm_step'


exporting
defaultoption = 'y'
textline1 = popup_text1
textline2 = popup_text2
titel = 'order screening queue management'
exceptions
others = 1.
if sy-ucomm = 'yes'.

move 'y' to rcode.

select *
from zvs13
into table int_release
where vbeln = zvs13-vbeln
and stonr <> 30
and stonr <> 20.

top_line = 1.
set screen 800.
leave screen.

elseif sy-ucomm = 'no' or


sy-ucomm = 'canc'.
set screen 100. leave screen.
endif.
else.
select * from zvs24t
where zpopup = 'notinqueue'
and spras = sy-langu.
endselect.
if sy-subrc = 0.
move zvs24t-zpopdes to popup_text1.
move zvs24t-zpopdes+35(35) to popup_text2.
else.
move ' this order is not being held ' to popup_text1.
move ' in queue management ' to popup_text2.
endif.

call function 'popup_to_display_text'


exporting
titel = ' order screening queue management '
textline1 = popup_text1
textline2 = popup_text2
exceptions
others = 1.
move 'cont' to sy-ucomm.
* call screen 600 starting at 11 06 ending at 50 13.
endif.
endform. " selection_order_status
*&---------------------------------------------------------------------*
*& form selection_reveiw_screen *
*&---------------------------------------------------------------------*
form selection_reveiw_screen.

select single * from zvs50 where vbeln = zvs13-vbeln.

if sy-subrc = 0.
move 'order screening - queue management' to popup_title.
concatenate 'sales document' zvs13-vbeln
'is being processed by' zvs50-ernam into field separated by ' '
.
concatenate 'on date ' zvs50-erdat 'at time' zvs50-uzeit
into field1 separated by ' '.
call function 'popup_to_inform'
exporting
titel = popup_title
txt1 = field
txt2 = field1
exceptions
others = 1.

clear ok_code100.

else. " beln = zvs13-vbeln.


select *
from zvs13
into table int_zvs13
where vbeln = zvs13-vbeln
and stonr <> 40
and stonr <> 50.

describe table int_zvs13 lines lin_no.


if lin_no = 0.
else.
*zvs50-ernam = sy-uname.
*zvs50-erdat = sy-datum.
*zvs50-vbeln = zvs13-vbeln.
*zvs50-uzeit = sy-uzeit.
append *zvs50.
insert into zvs50 values *zvs50.
endif.
endif.
select *
from zvs13
into table int_zvs13
where vbeln = zvs13-vbeln
and stonr <> 40
and stonr <> 50.

if zvs50-vbeln = zvs13-vbeln.
clear zvs13-vbeln.
clear zvs50-vbeln.
set screen 100.leave screen.
else.
clear ok_code100.
top_line = 1.
set screen 300.
leave screen.
endif.
endform. " selection_reveiw_screen
*&---------------------------------------------------------------------*
*& form pop_up_for_item_release
*&---------------------------------------------------------------------*
form pop_up_for_item_release.

call function 'popup_to_display_text'


exporting
titel = 'order screening queue management '
textline1 = 'no items have been released '
textline2 = 'from the queue '
exceptions
others = 1.
if sy-ucomm = 'yes'.
set screen 300. leave screen.
endif.
endform. " pop_up_for_item_release
*&---------------------------------------------------------------------*
*& form view_released_orders
*&---------------------------------------------------------------------*
* to view the partially released orders
*&---------------------------------------------------------------------*
form view_released_orders.

select *
from zvs13
where vbeln = vbak-vbeln
and stonr <> 20
and stonr <> 30.
endselect.
if sy-subrc = 0.
if w_zcland is initial.
select *
from zvs13
into table int_release
where vbeln = vbak-vbeln
and stonr <> 20
and stonr <> 30.
else.
select *
from zvs13
into table int_release
where vbeln = vbak-vbeln
and stonr <> 20
and stonr <> 30
and ( zcland = w_zcland ).
endif.
if sy-subrc = 0.

set screen 800.


leave screen.
else.
perform pop_up_for_item_release.

endif.
else.
perform pop_up_for_item_release.
endif.
endform. " view_released_orders
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& form contact_person_address
*&---------------------------------------------------------------------*
form contact_person_address.
clear vbak-kunnr.
loop at vbpa1.
move vbpa1-parnr to vbak-kunnr.
endloop.
* refresh ksadr.
refresh ktab1.
loop at vbpa1.
perform get_sadr_address using vbpa1-adrnr.
* select * from sadr into table ksadr
* where adrnr = vbpa1-adrnr.
endloop.
if vbpa1-adrnr is initial.
select single * from knvk into xknvk
where parnr = vbpa1-parnr.

loop at xknvk.
endloop.
perform get_sadr_address using xknvk-adrnd.
endif.
* select * from sadr into table xsadrx where adrnr = xknvk-adrnd.
* loop at xsadrx.

* move xsadrx-name1 to name1.


* move xsadrx-name2 to name2.
* move xsadrx-name3 to name3.
* move xsadrx-name4 to name4.
* move xsadrx-ort01 to ort01.
* move xsadrx-stras to stras.
* move xsadrx-regio to regio.
* move xsadrx-land1 to land.
* move xsadrx-pstlz to pstlz.
* endloop.

* else.
* loop at ksadr.
move ksadr-name1 to name1.
move ksadr-name2 to name2.
move ksadr-name3 to name3.
move ksadr-name4 to name4.
move ksadr-ort01 to ort01.
move ksadr-stras to stras.
move ksadr-regio to regio.
move ksadr-land1 to land.
move ksadr-pstlz to pstlz.
move ksadr-telf1 to telf1.
move ksadr-telfx to telfx.
* endloop.
* endif.

endform. " contact_person_address


*&---------------------------------------------------------------------*
*& form ascending_columns_selected
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form ascending_columns_selected.

loop at sigma-cols into wa.


if wa-selected = 'x'.
move 'x' to wa-selected.
field-name = wa.
if field-name(5) = 'zvs13'. "jjjh/dc 04/02/2003
shift field-name by six places.
else. "jjjh/dc 04/02/2003
shift field-name by 5 places. "jjjh/dc 04/02/2003
endif. "jjjh/dc 04/02/2003
move field-name to wa.
sort itab ascending by (wa-screen-name).
endif.
endloop.
endform. " ascending_columns_selected
*&---------------------------------------------------------------------*
*& form descending_columns_selected
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form descending_columns_selected.

loop at sigma-cols into wa.


if wa-selected = 'x'.
move 'x' to wa-selected.
field-name = wa.
if field-name(5) = 'zvs13'. "jjjh/dc 04/02/2003
shift field-name by six places.
else. "jjjh/dc 04/02/2003
shift field-name by 5 places. "jjjh/dc 04/02/2003
endif. "jjjh/dc 04/02/2003
move field-name to wa.
sort itab descending by (wa-screen-name).
endif.
endloop.
endform. " descending_columns_selected
*&---------------------------------------------------------------------*
*& form read_table_chk_tab1
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form read_table_chk_tab1.

read table chk_tab1 index tabix.


modify chk_tab1 index tabix.
move chk_tab1-vbeln to *zvs50-vbeln.
move sy-uname to *zvs50-ernam.
move sy-datum to *zvs50-erdat.
move sy-uzeit to *zvs50-uzeit.
append *zvs50.
insert into zvs50 values *zvs50.
clear ok_code200.

endform. " read_table_chk_tab1


*&---------------------------------------------------------------------*
*& form selection_of_table_zvs13
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form selection_of_table_zvs13.

ranges: s_vkorg for zvs13-vkorg. "$7


ranges: s_zcomtyp for zvs13-zcomtyp.
ranges: s_zlictyp for zvs13-zlictyp.
ranges: s_stonr for zvs13-stonr.
ranges: s_zqueid for zvs13-zqueid.
ranges: s_vbeln for zvs13-vbeln.
ranges: s_kunnr for zvs13-kunnr.
ranges: s_vsbed for zvs13-vsbed.
ranges: s_route for zvs13-route.
ranges: s_land1 for zvs13-land1.
ranges: s_zcland for zvs13-zcland.
ranges: s_erdat for zvs13-erdat.

select *
from zvs50
into table *zvs50.

if not w_sales_org is initial. "$7


move w_sales_org to s_vkorg-low. "$7
move 'eq' to s_vkorg-option. "$7
move 'i' to s_vkorg-sign. "$7
append s_vkorg. "$7
endif.

if not w_zcomtyp is initial.


move w_zcomtyp to s_zcomtyp-low.
move 'eq' to s_zcomtyp-option.
move 'i' to s_zcomtyp-sign.
append s_zcomtyp.
endif.

if not w_zlictyp is initial.


move w_zlictyp to s_zlictyp-low.
move 'eq' to s_zlictyp-option.
move 'i' to s_zlictyp-sign.
append s_zlictyp.
endif.

if not w_stonr is initial.


move w_stonr to s_stonr-low.
move 'eq' to s_stonr-option.
move 'i' to s_stonr-sign.
append s_stonr.
endif.

if not w_zqueid is initial.


move w_zqueid to s_zqueid-low.
move 'eq' to s_zqueid-option.
move 'i' to s_zqueid-sign.
append s_zqueid.
endif.

if not w_vbeln is initial.


move w_vbeln to s_vbeln-low.
move 'eq' to s_vbeln-option.
move 'i' to s_vbeln-sign.
append s_vbeln.
endif.

if not w_kunnr is initial.


move w_kunnr to s_kunnr-low.
move 'eq' to s_kunnr-option.
move 'i' to s_kunnr-sign.
append s_kunnr.
endif.

if not w_vsbed is initial.


move w_vsbed to s_vsbed-low.
move 'eq' to s_vsbed-option.
move 'i' to s_vsbed-sign.
append s_vsbed.
endif.

if not w_route is initial.


move w_route to s_route-low.
move 'eq' to s_route-option.
move 'i' to s_route-sign.
append s_route.
endif.

if not w_land1 is initial.


move w_land1 to s_land1-low.
move 'eq' to s_land1-option.
move 'i' to s_land1-sign.
append s_land1.
endif.

if not w_zcland is initial.


move w_zcland to s_zcland-low.
move 'eq' to s_zcland-option.
move 'i' to s_zcland-sign.
append s_zcland.
endif.

if not w_erdat is initial.


move w_erdat to s_erdat-low.
move 'lt' to s_erdat-option.
move 'e' to s_erdat-sign.
append s_erdat.
endif.

if not w_erdat1 is initial.


move w_erdat1 to s_erdat-low.
move 'gt' to s_erdat-option.
move 'e' to s_erdat-sign.
append s_erdat.
endif.

select *
from zvs13
into table itab
where ( stonr = '20' or
stonr = '30' )
and vkorg in s_vkorg "$7
and zcomtyp in s_zcomtyp
and zlictyp in s_zlictyp
and stonr in s_stonr
and zqueid in s_zqueid
and vbeln in s_vbeln
and kunnr in s_kunnr
and vsbed in s_vsbed
and route in s_route
and land1 in s_land1
and zcland in s_zcland
and erdat in s_erdat.

sigma-top_line = 1.
if not plant is initial.
delete itab where zshipno <> plant.
endif.

loop at itab.
select single werks
from vbap
into itab-werks
where vbeln = itab-vbeln
and posnr = itab-posnr.
if sy-subrc = 0.
if not w_delivering_plant is initial.
if itab-werks <> w_delivering_plant.
delete itab.
continue.
endif.
endif.
modify itab transporting werks.
endif.

select single bsark


kdgrp
bstkd
from vbkd
into (itab-bsark,
itab-kdgrp,
itab-bstkd)
where vbeln = itab-vbeln
and posnr = 000000.
if sy-subrc = 0.
if not w_ordering_method is initial.
if itab-bsark <> w_ordering_method.
delete itab.
continue.
endif.
endif.
modify itab transporting bsark kdgrp bstkd. "$8
endif.

select single lifsp


from vbep
into itab-lifsp
where vbeln = itab-vbeln
and posnr = itab-posnr.
if sy-subrc = 0.
modify itab transporting lifsp. "$8
endif.

select single name1


from kna1
into itab-name1
where kunnr = itab-kunnr.
if sy-subrc = 0.
modify itab transporting name1. "$8
endif.

select single fixkz "$8


from eban "$8
into itab-fixkz "$8
where banfn = itab-vbeln. "$8
if sy-subrc = 0. "$8
modify itab transporting fixkz. "$8
endif. "$8

endloop.

if exclude_delayed = 'x'.
delete itab where zohdat > sy-datum
and zohind = 'x'.
delete itab where zohdat = sy-datum
and zohtim > sy-uzeit
and zohind = 'x'.
endif.
if only_delayed = 'x'.
delete itab where zohind <> 'x'.

delete itab where zohdat < sy-datum


and zohind = 'x'.
delete itab where zohdat = sy-datum
and zohtim < sy-uzeit
and zohind = 'x'.
endif.
endform. " selection_of_table_zvs13
*eject
*&---------------------------------------------------------------------*
*& form customer_transaction_xd02
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form customer_transaction_xd02.

move kna1-kunnr to rf02d-kunnr.


move '110324' to debi-auswl .

if debi-auswl cs '110'.
rf02d-d0110 = 'x'.
endif.
if debi-auswl cs '324'.
rf02d-d0324 = 'x'.
endif.
set parameter id 'kun' field rf02d-kunnr.
set parameter id 'ddy' field debi-auswl .
call transaction 'xd02' .

endform. " customer_transaction_xd02


*&---------------------------------------------------------------------*
*& form customer_transaction_xd03
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
form customer_transaction_xd03.

move kna1-kunnr to rf02d-kunnr.


move '110324' to debi-auswl .

if debi-auswl cs '110'.
rf02d-d0110 = 'x'.
endif.
if debi-auswl cs '324'.
rf02d-d0324 = 'x'.
endif.
set parameter id 'kun' field rf02d-kunnr.
set parameter id 'ddy' field debi-auswl .
call transaction 'xd03' .

endform. " customer_transaction_xd02


*&---------------------------------------------------------------------*
*& form link_to_threshold_viewing
*&---------------------------------------------------------------------*
form link_to_threshold_viewing.
refresh ck_tab.
clear ck_tab.
loop at int_zvs13.
if int_zvs13-checkbox = 'x'.
move-corresponding int_zvs13 to ck_tab.
append ck_tab.
endif.
endloop.

numr = 1.
read table ck_tab index numr.
clear ok_code300.

move ck_tab-zcland to zvs20-zcland.


set parameter id 'zcc' field zvs20-zcland.
move ck_tab-zlictyp to zvs20-zlictyp.
set parameter id 'zlt' field zvs20-zlictyp.
select single * from zvs12 where zlictyp = zvs20-zlictyp
and zcland = zvs20-zcland.
if sy-subrc = 0.
select single * from zvs17 where zscrgrp = zvs12-zscrgrp.
if sy-subrc = 0.
move zvs17-parvw to vbpa-parvw.
set parameter id 'par' field vbpa-parvw.
select single kunnr into customer_number
from vbpa where vbeln = ck_tab-vbeln
and posnr = '000000'
and parvw = zvs17-parvw.
if sy-subrc = 0.
move customer_number to zvs20-kunnr.
set parameter id 'kun' field zvs20-kunnr.
call transaction 'zvs5' and skip first screen.
endif.
endif.
endif.
endform. " link_to_threshold_viewing
*
form link_to_license_set_up.
data ws_process_mode(1).
data ws_table(5).
refresh ck_tab.
clear ck_tab.
loop at int_zvs13.
if int_zvs13-checkbox = 'x'.
move-corresponding int_zvs13 to ck_tab.
append ck_tab.
endif.
endloop.

numr = 1.
read table ck_tab index numr.
clear ok_code300.

set parameter id 'zcc' field ck_tab-zcland.


set parameter id 'zlt' field ck_tab-zlictyp.

select single * from zvs12 where zlictyp = ck_tab-zlictyp


and zcland = ck_tab-zcland.
if sy-subrc = 0.
select single * from zvs17 where zscrgrp = zvs12-zscrgrp.
if sy-subrc = 0.
move zvs17-parvw to vbpa-parvw.
set parameter id 'par' field vbpa-parvw.
select single kunnr into customer_number
from vbpa where vbeln = ck_tab-vbeln
and posnr = '000000'
and parvw = zvs17-parvw.
if sy-subrc = 0.
set parameter id 'kun' field customer_number.
endif.
endif.
endif.

move 'd' to ws_process_mode. " display


move 'zvs10' to ws_table.
export memory_process_mode from ws_process_mode
memory_table from ws_table
to memory id 'zvs30scr_process_mode'.
call transaction 'zvs3'.
*
* move ck_tab-zcland to zvs20-zcland.
* set parameter id 'zcc' field zvs20-zcland.
* move ck_tab-zlictyp to zvs20-zlictyp.
* set parameter id 'zlt' field zvs20-zlictyp.
* select single * from zvs12 where zlictyp = zvs20-zlictyp
* and zcland = zvs20-zcland.
* if sy-subrc = 0.
* select single * from zvs17 where zscrgrp = zvs12-zscrgrp.
* if sy-subrc = 0.
* move zvs17-parvw to vbpa-parvw.
* set parameter id 'par' field vbpa-parvw.
* select single kunnr into customer_number
* from vbpa where vbeln = ck_tab-vbeln
* and posnr = '000000'
* and parvw = zvs17-parvw.
* if sy-subrc = 0.
* move customer_number to zvs20-kunnr.
* set parameter id 'kun' field zvs20-kunnr.
** call transaction 'zreg' and skip first screen.
* endif.
* endif.
* endif.
endform. " link_to_threshold_viewing
*&---------------------------------------------------------------------*
*& form proc_creditcrd_new
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form proc_creditcrd_new.

data : ws_object(22), " object key for jcds.


ws_bypass(1), " bypass flag
ws_str(80),
h_sadr type sadr,
h_addr1_sel type addr1_sel.

* check if this order has been released from all the queue. a record
* with status code e0004 should exist in the table jcds.

refresh : t_jcds, ctab, x_jcds.


clear : ws_free.

concatenate 'vb' vbak-vbeln into ws_object.


concatenate 'objnr like ''' ws_object '%' '''' into ws_str.
move ws_str to ctab.
append ctab.

select * from jcds into table t_jcds where (ctab).

delete t_jcds where stat ne 'e0003'.

loop at t_jcds.

read table x_jcds with key objnr = t_jcds-objnr binary search.


if sy-subrc ne 0.
clear x_jcds.
move-corresponding t_jcds to x_jcds.
append x_jcds.
else.
move-corresponding t_jcds to x_jcds.
modify x_jcds index sy-tabix.
endif.
sort x_jcds by objnr.

endloop.

loop at x_jcds where stat = 'e0003' and inact = ' '.

endloop.

if sy-subrc ne 0.
clear : vbpa-kunnr.
select single kunnr adrnr from vbpa into (vbpa-kunnr, vbpa-adrnr)
where vbeln = vbak-vbeln and posnr = 0 and parvw = 're'.

if sy-subrc = 0 and ( vbpa-kunnr = '0099999000' or


vbpa-kunnr = '0099999001' ).
perform save_order.
endif.
endif.

endform. "proc_creditcrd_new
*&---------------------------------------------------------------------*
*& form save_order
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form save_order.

* refresh t_bdc.

refresh t_bdc.
clear t_bdc.

* screen 102 beginning.

clear t_bdc.
perform bdc_screen using 'sapmv45a' '0102'.

* move order number

clear t_bdc.
perform bdc_field using 'vbak-vbeln' vbak-vbeln.

* press f6 detail

clear t_bdc.
perform bdc_field using 'bdc_okcode' '=uer1'.

* screen 4001 beginning.

clear t_bdc.
perform bdc_screen using 'sapmv45a' '4001'.

* choose paymentcard tab

clear t_bdc.
perform bdc_field using 'bdc_okcode' '=krpl'.

* screen 4001 beginning.

clear t_bdc.
perform bdc_screen using 'saplv60f' '4001'.

* press back tab.

clear t_bdc.
perform bdc_field using 'bdc_okcode' '=s\back'.

* display screen 4001.

clear t_bdc.
perform bdc_screen using 'sapmv45a' '4001'.

* save order.

clear t_bdc.
perform bdc_field using 'bdc_okcode' '=sich'.

* call transaction va02

call transaction 'va02' using t_bdc mode 'n' messages


into t_message.

* loop thru the messages display message.

loop at t_message where msgnr = '311' and msgid = 'v1'.


endloop.

if sy-subrc = 0.
popup_title = 'sales document save'.
move vbak-vbeln to ws_vbeln.
condense ws_vbeln.
concatenate 'sales document ' ws_vbeln 'has been'
'saved successfully'
into ws_field1 separated by ' '.
move 'press continue.' to ws_field2.

call function 'popup_to_inform'


exporting
titel = popup_title
txt1 = ws_field1
txt2 = ws_field2
exceptions
others = 1.

else.

popup_title = 'sales document save'.


move vbak-vbeln to ws_vbeln.
condense ws_vbeln.
concatenate 'error occured while saving '
'order' ws_vbeln
into ws_field1 separated by ' '.
move 'press continue.' to ws_field2.

call function 'popup_to_inform'


exporting
titel = popup_title
txt1 = ws_field1
txt2 = ws_field2
exceptions
others = 1.

endif.
endform. "save_order

*&---------------------------------------------------------------------*
*& form proc_creditcrd
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form proc_creditcrd.

data : ws_object(22), " object key for jcds.


ws_bypass(1), " bypass flag
ws_str(80),
h_sadr type sadr,
h_addr1_sel type addr1_sel.

* check if this order has been released from all the queue. a record
* with status code e0004 should exist in the table jcds.

refresh : t_jcds, ctab, x_jcds.


clear : ws_free.

concatenate 'vb' vbak-vbeln into ws_object.


concatenate 'objnr like ''' ws_object '%' '''' into ws_str.
move ws_str to ctab.
append ctab.

select * from jcds into table t_jcds where (ctab).

delete t_jcds where stat ne 'e0003'.

loop at t_jcds.

read table x_jcds with key objnr = t_jcds-objnr binary search.


if sy-subrc ne 0.
clear x_jcds.
move-corresponding t_jcds to x_jcds.
append x_jcds.
else.
move-corresponding t_jcds to x_jcds.
modify x_jcds index sy-tabix.
endif.
sort x_jcds by objnr.

endloop.

loop at x_jcds where stat = 'e0003' and inact = ' '.

endloop.

if sy-subrc ne 0.

* check if order is complete.

clear : ws_complete.
select single * from vbuk where vbeln = vbak-vbeln.
if sy-subrc = 0.
if vbuk-uvall = 'c' and vbuk-uvvlk = 'c' and vbuk-uvfak = 'c' and
vbuk-uvprs = 'c'.
move 'y' to ws_complete.
endif.
endif.

* check if this is one time customer.

clear : vbpa-kunnr.
select single kunnr adrnr from vbpa into (vbpa-kunnr, vbpa-adrnr)
where vbeln = vbak-vbeln and posnr = 0 and parvw = 're'.

if sy-subrc = 0 and ( vbpa-kunnr = '0099999000' or


vbpa-kunnr = '0099999001' ) and ws_complete = 'y'.

* if this is one time customer ( domestic / international ), check if


* this is credit card order.

refresh : t_zccdatam, t_zccdatad, t_vbap.


clear : ws_value, ws_vbapl, ws_bypass.

select * from zccdatam into table t_zccdatam where vbeln =


vbak-vbeln.

if sy-subrc = 0.

* check if authorization already exits. if yes do not authorize again.

move 'n' to ws_bypass.

select * from zccdatad into table t_zccdatad where vbeln =


vbak-vbeln.
if sy-subrc = 0.
loop at t_zccdatad.
if t_zccdatad-zzccrestyp eq 's' and
t_zccdatad-zzccreason eq '100' and
t_zccdatad-zzccauthus ne 'y' and
t_zccdatad-zzccnetwr gt 1 and
t_zccdatad-zzccauthex ge sy-datum.
move 'y' to ws_bypass.
endif.
endloop.
else.
move 'n' to ws_bypass.
endif.

* prepare structure for calling function module.

if ws_bypass = 'n'.

* calculate value for this order.

select * from vbap into table t_vbap where


vbeln = vbak-vbeln.

loop at t_vbap where prsok = 'x' and


( abgru eq ' ' or abgru eq 'c1' or
abgru eq 'c3' or abgru = 'c2' ).
ws_value = ws_value + t_vbap-netwr.
* "$1d start of change
* !!!!! this is an incorrect line in the us code too. they have also
* changed it in the pricing upgrade!!
* ws_value = ws_value + t_vbap-kzwi1 + t_vbap-zzwi05. "$1d
ws_value = ws_value + t_vbap-mwsbp."tax field copied from us
* "$1d end of change
* add 1 to ws_vbapl.
endloop.

* conver the currency.

if t_vbap-waerk <> 'usd' and t_vbap-waerk <> space.


select single kursk from vbkd into vbkd-kursk where
vbeln = vbak-vbeln and posnr = 0.
select single ffact tfact from tcurf
into (tcurf-ffact, tcurf-tfact) where
kurst = 'm' and fcurr = t_vbap-waerk
and tcurr = 'usd'.
ws_value = ws_value * vbkd-kursk * tcurf-tfact.
ws_value = ws_value / 100000.
endif.

* check ws_value if zero, if yes, check item category if they are


* for free item, set free category variable.

if ws_value = 0.
move 'y' to ws_free.
loop at t_vbap where abgru eq ' ' or abgru eq 'c1' or
abgru eq 'c3' or abgru eq 'c2'.
if t_vbap-pstyv ne 'renn' and
t_vbap-pstyv ne 'tann' and
t_vbap-pstyv ne 'zann' and
t_vbap-pstyv ne 'zgcn' and
t_vbap-pstyv ne 'zktn' and
t_vbap-pstyv ne 'zmtn' and
t_vbap-pstyv ne 'zrek' and
t_vbap-pstyv ne 'ztmn' and
t_vbap-pstyv ne 'ztqn' and
t_vbap-pstyv ne 'zcmk' and
t_vbap-pstyv ne 'zcom' and
t_vbap-pstyv ne 'zxqi'.
move 'n' to ws_free.
exit.
endif.
endloop.

endif.

* all the items are free send message no authorization required.

if ws_free = 'y'.
popup_title = 'sales order with free items'.
move 'no authorization required.' to ws_field1.
move 'press continue.' to ws_field2.
call function 'popup_to_inform'
exporting
titel = popup_title
txt1 = ws_field1
txt2 = ws_field2
exceptions
others = 1.
perform remov_delblk.
exit.
endif.

clear : zcrd_info, zcrd_retn.

read table t_zccdatam index 1.


move vbak-vbeln to zcrd_info-vbeln.
move t_zccdatam-zzccard to zcrd_info-ccard.
move t_zccdatam-zzccmop to zcrd_info-ccmop.
move t_zccdatam-zzccmbrno to zcrd_info-ccref.
move t_zccdatam-zzccexpdt to zcrd_info-ccexp.
move t_zccdatam-zzcccidcvv to zcrd_info-idnum.
move ws_value to zcrd_info-value.
move vbpa-kunnr to zcrd_info-kunnr.
move sy-datum to zcrd_info-zzccreqdat.
move sy-uzeit to zcrd_info-zzccreqtim.

* get address

* select single * from sadr where adrnr = vbpa-adrnr.


* if sy-subrc = 0.
* move sadr-telf1 to zcrd_info-zztelno.
* move sadr-name1 to zcrd_info-zzname1.
* move sadr-stras to zcrd_info-zzname2.
* move sadr-name3 to zcrd_info-zzname3.
* move sadr-ort01 to zcrd_info-zzcity.
* move sadr-regio to zcrd_info-zzstate.
* move sadr-pstlz to zcrd_info-zzzip.
* endif.

h_addr1_sel-addrnumber = vbpa-adrnr.

call function 'addr_get'


exporting
address_selection = h_addr1_sel
importing
sadr = h_sadr
exceptions
parameter_error = 0
address_not_exist = 0
version_not_exist = 0
internal_error = 0
others = 0.

if sy-subrc = 0.
move h_sadr-telf1 to zcrd_info-zztelno.
move h_sadr-name1 to zcrd_info-zzname1.
move h_sadr-name2 to zcrd_info-zzname2.
move h_sadr-name3 to zcrd_info-zzname3.
move h_sadr-ort01 to zcrd_info-zzcity.
move h_sadr-regio to zcrd_info-zzstate.
move h_sadr-pstlz to zcrd_info-zzzip.
endif.

* validate credit card information.

call function 'z_ccrd_validate_information'


exporting
zcrd_info = zcrd_info
importing
zcrd_retn = zcrd_retn
exceptions
others = 1.

if sy-subrc = 0.

if zcrd_retn-zzerrrslt ne 's'.
if zcrd_retn-zzrspno ne '000'.
perform order_reject tables t_vbap.
perform updat_detail using zcrd_info zcrd_retn.
else.
perform updat_detail using zcrd_info zcrd_retn.
endif.
else.
perform updat_detail using zcrd_info zcrd_retn.
loop at t_vbap where abgru = 'c1' or abgru = 'c2' or
abgru = 'c3'.
endloop.
if sy-subrc = 0.
perform remov_reject tables t_vbap.
endif.
perform remov_delblk.
endif.

else.

* change zcrd_retn, create record with batch flg

move 'd' to zcrd_retn-zzerrrslt.


move '000' to zcrd_retn-zzerrcode.
move 'resend' to zcrd_retn-zzerractn.
perform updat_detail using zcrd_info zcrd_retn.
endif.

endif.

endif.

endif.

endif.

endform. " proc_creditcrd


*&---------------------------------------------------------------------*
*& form updat_detail
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form updat_detail using zcrd_info structure zcrd_info
zcrd_retn structure zcrd_retn.

* create detail record.

refresh : t_zccdatad.
clear : t_zccdatad.
move vbak-vbeln to t_zccdatad-vbeln.
move zcrd_info-zzccreqdat to t_zccdatad-zzccreqdat.
move zcrd_info-zzccreqtim to t_zccdatad-zzccreqtim.
move zcrd_info-ccmop to t_zccdatad-zzccmop.
move zcrd_info-ccard to t_zccdatad-zzccard.
move zcrd_info-ccexp to t_zccdatad-zzccexpdt.
move zcrd_info-ccref to t_zccdatad-zzccmbrno.
if zcrd_retn-zzavsrsp = 'n1'.
move 'n' to t_zccdatad-zzccavsavv.
else.
move 'y' to t_zccdatad-zzccavsavv.
endif.
move zcrd_info-value to t_zccdatad-zzccnetwr.
move zcrd_retn-zzerrrslt to t_zccdatad-zzccrestyp.
move zcrd_retn-zzrspno to t_zccdatad-zzccreason.
move zcrd_retn-zzrspdt to t_zccdatad-zzccrespdt.
move zcrd_retn-zzccresptm to t_zccdatad-zzccresptm.
move zcrd_retn-zzautcod to t_zccdatad-zzccauthcd.
move zcrd_retn-zzerractn to t_zccdatad-zzccaction.
move zcrd_retn-zzavsrsp to t_zccdatad-zzavsrsp.
move zcrd_retn-zzscvlrs to t_zccdatad-zzscvlrs.

select single vbtyp from vbak into vbak-vbtyp where vbeln =


zcrd_info-vbeln.
move vbak-vbtyp to t_zccdatad-zzccsource.

if zcrd_retn-zzerrrslt = 's'.
select single zvalue1 from zliteral into zliteral-zvalue1 where
zkey1 = 'zccrd' and zkey2 = zcrd_info-ccmop and zkey3 = 0.

move zliteral-zvalue1 to ws_wrkdys.


ws_wrkdt = sy-datum + ws_wrkdys.
move ws_wrkdt to t_zccdatad-zzccauthex.
endif.

if zcrd_retn-zzrspno = '000'.
move 'y' to t_zccdatad-zzccbch.
endif.
move sy-datum to t_zccdatad-erdat.
move sy-uname to t_zccdatad-ernam.

append t_zccdatad.

insert zccdatad from table t_zccdatad.

endform. " updat_detail


*&---------------------------------------------------------------------*
*& form remov_delblk
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form remov_delblk.

* refresh t_bdc.

refresh t_bdc.
clear t_bdc.

* screen 102 beginning.

clear t_bdc.
perform bdc_screen using 'sapmv45a' '0102'.

* move order number

clear t_bdc.
perform bdc_field using 'vbak-vbeln' vbak-vbeln.

* press f5 detail

clear t_bdc.
perform bdc_field using 'bdc_okcode' '/5'.

* screen 4001 beginning.

clear t_bdc.
perform bdc_screen using 'sapmv45a' '4001'.

* overview shipping.

* clear t_bdc.
* perform bdc_field using 'bdc_okcode' 'uver'.

* screen 403 beginning.

* clear t_bdc.
* perform bdc_screen using 'sapmv45a' '0403'.

* clear delivery block.

clear t_bdc.
perform bdc_field using 'vbak-lifsk' ' '.

* press f11 save.

clear t_bdc.
perform bdc_field using 'bdc_okcode' 'sich'.

* call transaction va02 to remove delivery block.

set parameter id 'zce' field 'bdc'.


call transaction 'va02' using t_bdc mode 'e' messages
into t_message.
set parameter id 'zce' field ' '.

* loop thru the messages display message.

loop at t_message where msgnr = '311' and msgid = 'v1'.


message s059.
endloop.

* remove credit block

do 2 times.
call function 'rzl_sleep'
exporting
seconds = 4
exceptions
argument_error = 1
others = 2.
enddo.

move vbak-vbeln to wx_vbeln.


move 'crrl' to wx_callact.

call function 'sd_sales_document_read'


exporting
document_number = wx_vbeln
call_active = wx_callact
exceptions
others = 1.

call function 'sd_sales_document_perform'


exporting
in_program = 'sapfv45k'
perform = 'kredit_freigabe'
exceptions
others = 1.

call function 'sd_sales_document_save'


exporting
synchron = 'x'
exceptions
others = 1.

endform. " remov_delblk

*&---------------------------------------------------------------------*
*& form bdc_field
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form bdc_field using fname fval.

move: fname to t_bdc-fnam,


fval to t_bdc-fval.
append t_bdc.
clear t_bdc.

endform. " bdc_field

*&---------------------------------------------------------------------*
*& form bdc_screen
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form bdc_screen using progname screenno.

move : progname to t_bdc-program,


screenno to t_bdc-dynpro,
'x' to t_bdc-dynbegin.
append t_bdc.
clear t_bdc.

endform. " bdc_screen


*&---------------------------------------------------------------------*
*& form order_reject
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form order_reject tables t_vbap structure vbap.

* refresh t_bdc.

refresh t_bdc.
clear t_bdc.

* screen 102 beginning.

clear t_bdc.
perform bdc_screen using 'sapmv45a' '0102'.

* move order number

clear t_bdc.
perform bdc_field using 'vbak-vbeln' vbak-vbeln.

* press f6 detail

clear t_bdc.
perform bdc_field using 'bdc_okcode' '=uer1'.

* screen 4001 beginning.

clear t_bdc.
perform bdc_screen using 'sapmv45a' '4001'.
* select all the lines.

* clear t_bdc.
* perform bdc_field using 'bdc_okcode' 'hkal'.

describe table t_vbap lines ws_vbapl.

* item status.

* clear t_bdc.
* perform bdc_field using 'bdc_okcode' 'psta'.

**screen 456 beginning.

* clear t_bdc.
* perform bdc_screen using 'sapmv45a' '0456'.

* choose item detail tab

clear t_bdc.
perform bdc_field using 'bdc_okcode' '=t\03'.

* screen 4001 beginning.

clear t_bdc.
perform bdc_screen using 'sapmv45a' '4001'.

* put rejection code.

if ws_vbapl = 1.

clear t_bdc.
read table t_vbap index sy-index.
if sy-subrc = 0 and t_vbap-abgru = ' '.
perform bdc_field using 'vbap-abgru' 'c1'.
endif.

clear t_bdc.
perform bdc_field using 'bdc_okcode' '=sich'.

else.

do ws_vbapl times.

clear t_bdc.
read table t_vbap index sy-index.
if sy-subrc = 0 and t_vbap-abgru = ' '.
perform bdc_field using 'vbap-abgru' 'c1'.
endif.

if sy-index lt ws_vbapl.
clear t_bdc.
perform bdc_field using 'bdc_okcode' '=itpp'.
clear t_bdc.
perform bdc_screen using 'sapmv45a' '4001'.
else.
clear t_bdc.
perform bdc_field using 'bdc_okcode' '=sich'.
endif.

enddo.

endif.

* call transaction va02 to reject lines.

set parameter id 'zce' field 'bdc'.


call transaction 'va02' using t_bdc mode 'e' messages
into t_message.
set parameter id 'zce' field ' '.

* loop thru the messages display message.

loop at t_message where msgnr = '311' and msgid = 'v1'.


endloop.

* records are updated successfully.

if sy-subrc = 0.

popup_title = 'sales document rejection'.


move vbak-vbeln to ws_vbeln.
condense ws_vbeln.
concatenate 'sales document ' ws_vbeln 'has been'
'rejeceted because '
into ws_field1 separated by ' '.
concatenate 'of invalid credit card information.'
'press continue.' into ws_field2 separated by ' '.
call function 'popup_to_inform'
exporting
titel = popup_title
txt1 = ws_field1
txt2 = ws_field2
exceptions
others = 1.
endif.

endform. " order_reject

*&---------------------------------------------------------------------*
*& form remov_reject
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form remov_reject tables t_vbap structure vbap.

* refresh t_bdc.

refresh t_bdc.
clear t_bdc.

* screen 102 beginning.


clear t_bdc.
perform bdc_screen using 'sapmv45a' '0102'.

* move order number

clear t_bdc.
perform bdc_field using 'vbak-vbeln' vbak-vbeln.

* press f6 detail

clear t_bdc.
perform bdc_field using 'bdc_okcode' '=uer1'.

* screen 4001 beginning.

clear t_bdc.
perform bdc_screen using 'sapmv45a' '4001'.

* select all the lines.

* clear t_bdc.
* perform bdc_field using 'bdc_okcode' 'hkal'.

describe table t_vbap lines ws_vbapl.

* item status.

* clear t_bdc.
* perform bdc_field using 'bdc_okcode' 'psta'.

* choose item detail tab

clear t_bdc.
perform bdc_field using 'bdc_okcode' '=t\03'.

* screen 4001 beginning.

clear t_bdc.
perform bdc_screen using 'sapmv45a' '4001'.

* put rejection code.

if ws_vbapl = 1.

clear t_bdc.
read table t_vbap index sy-index.
if sy-subrc = 0 and ( t_vbap-abgru = 'c1' or
t_vbap-abgru = 'c2' or t_vbap-abgru = 'c3' ).
perform bdc_field using 'vbap-abgru' ' '.
endif.

clear t_bdc.
perform bdc_field using 'bdc_okcode' '=sich'.

else.

do ws_vbapl times.
clear t_bdc.
read table t_vbap index sy-index.
if sy-subrc = 0 and ( t_vbap-abgru = 'c1' or
t_vbap-abgru = 'c2' or t_vbap-abgru = 'c3' ).
perform bdc_field using 'vbap-abgru' ' '.
endif.

if sy-index lt ws_vbapl.
clear t_bdc.
perform bdc_field using 'bdc_okcode' '=itpp'.
clear t_bdc.
perform bdc_screen using 'sapmv45a' '4001'.
else.
clear t_bdc.
perform bdc_field using 'bdc_okcode' '=sich'.
endif.

enddo.

endif.

* call transaction va02 to reject lines.

set parameter id 'zce' field 'bdc'.


call transaction 'va02' using t_bdc mode 'e' messages
into t_message.
set parameter id 'zce' field ' '.

* loop thru the messages display message.

loop at t_message where msgnr = '311' and msgid = 'v1'.


endloop.

* allow transaction to complete.

do 2 times.
call function 'rzl_sleep'
exporting
seconds = 4
exceptions
argument_error = 1
others = 2.
enddo.

endform. " order_reject


*&---------------------------------------------------------------------*
*& form get_sadr_address
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->p_vbpa1_adrnr text
* -->p_table text
* -->p_ksadr text
*----------------------------------------------------------------------*
form get_sadr_address using p_vbpa1_adrnr.

data: ws_sadr type sadr,


ws_addr_sel type addr1_sel.

ws_addr_sel-addrnumber = p_vbpa1_adrnr.

call function 'addr_get'


exporting
address_selection = ws_addr_sel
importing
sadr = ksadr
exceptions
parameter_error = 1
address_not_exist = 2
version_not_exist = 3
internal_error = 4
others = 5.
.
if sy-subrc <> 0.
endif.

endform. " get_sadr_address


*&---------------------------------------------------------------------*
*& module get_default_country output
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module get_default_country output.
tables: usr05.
tables: tvko.

data: begin of i_usr05 occurs 0.


include structure usr05.
data: end of i_usr05.

clear zvs13-zcland.
select * from usr05 into table i_usr05
where bname = sy-uname.
loop at i_usr05.
if i_usr05-parid = 'vko'. " parameter for sales org
select single * from tvko " read sales organization table
where vkorg = i_usr05-parva.
if sy-subrc = 0.
perform get_sadr_address using tvko-adrnr.
if sy-subrc = 0.
move ksadr-land1 to zvs13-zcland.
endif.
endif.
endif.
endloop.

if zvs13-zcland is initial.
move 'de' to zvs13-zcland.
endif.

if plant is initial.
clear eban-werks.
endif.
endmodule. " get_default_country output
*eject
*---------------------------------------------------------------------*
* form get_pr_plant_country
*
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form get_pr_plant_country using p_banfn "$10
p_bnfpo "$10
changing p_land1. "$10

data: w_adrnr type adrnr. "$10


data: wc_addr1_sel like addr1_sel. "$10
data: w_sadr_t001w type sadr. "$10
data: w_t001w_land1 type land1. "$10
data: w_werks type werks_d. "$10

select single werks "$10


from eban "$10
into w_werks "$10
where banfn = xvbep-banfn "$10
and bnfpo = xvbep-bnfpo. "$10

if sy-subrc = 0. "$10
select single adrnr "$10
land1 "$10
from t001w "$10
into (w_adrnr, "$10
w_t001w_land1) "$10
where werks = w_werks. "$10
endif. "$10

if sy-subrc = 0. "$10
wc_addr1_sel-addrnumber = w_adrnr. "$10
call function 'addr_get' "$10
exporting "$10
address_selection = wc_addr1_sel "$10
importing "$10
sadr = w_sadr_t001w "$10
exceptions "$10
parameter_error = 1 "$10
address_not_exist = 2 "$10
version_not_exist = 3 "$10
internal_error = 4 "$10
others = 5. "$10

if sy-subrc = 0. "$10
move w_sadr_t001w-land1 to p_land1. "$10
else. "$10
move w_t001w_land1 to p_land1. " plant country. "$10
clear sy-subrc. "$10
endif. "$10
else. "$10
move 'de' to p_land1 . " plant country. "$10
endif. "$10

endform. "get_pr_plant_country "$10


*eject
include zvquemtl_f01.

Вам также может понравиться