on 02-18-2008 9:26 AM
Hi,
Someone knows smartforms and its program for picking list?.
I don't want to use sapscript SD_PICK_COLL and its program RVADSK01.
Thanks very much.
Matteo Vernile.
hi,
go through this code.
************************************************************
Program Description: *
A packing list is printed for each outbound delivery. *
Before the delivery is made to a customer the goods are *
packed in a box or any other container and to have a *
list of products put in the package packing list is *
required. This packing list will be printed upon pick *
confirmation or at a time the delivery note is created. *
*
REPORT z_sd_rep_000002 MESSAGE-ID zdevmsg.
********************TABLES USED***************************************
TABLES: likp, "SD Document: Delivery Header Data
lips, "SD document: Delivery: Item data
vbak, "Sales Document: Header Data
vbpa, "Sales Document: Partner
vbuk, "Sales Document: Header Status and Admin Data
vttp, "Shipment Item
vttk, "Shipment Header,
adrc, "Addresses (Business Address Services)
tvst, "Organizational Unit: Shipping Points
vbfa, "Sales Document Flow
kna1, "General Data in Customer Master
vepo, "Packing: Handling Unit Item (Contents)
vekp. "Handling Unit - Header Table
INCLUDE rvadtabl.
********************WORK AREA*****************************************
DATA : wa_zpacklist TYPE zpacklist, "structure to hold all the data
"that has to be passed to the
"smart form
wa_item TYPE LINE OF zitempack."workarea of main item struct
DATA : wa_item_lips TYPE LINE OF zitempack."wrkarea for data selected
"from LIPS table
********************INTERNAL TABLE************************************
DATA : i_item_lips TYPE zitempack, "Internal table for data
"selected from LIPS table
i_item TYPE zitempack. "main internal table for
"items data.
*****************************CONSTANTS********************************
CONSTANTS : c_posnn(1) TYPE c VALUE 'J',
YATHAM6 Insert Begin
c_vbtyp_v(1) type c VALUE 'C',
YATHAM6 Insert End
c_parvw_stp TYPE vbpa-parvw VALUE 'AG',
c_parvw_shp TYPE vbpa-parvw VALUE 'WE',
c_formname TYPE tdsfname VALUE 'Z_PACKINGLIST',
c_zdevmsg TYPE SY-MSGID value 'ZDEVMSG',
c_e TYPE SY-MSGTY VALUE 'E',
c_000 TYPE SY-MSGNO VALUE '000',
c_X(1) TYPE c VALUE 'X',
c_fully_picked(1) TYPE c VALUE 'C'.
***************************GLOBAL VARIABLE****************************
DATA : v_objnm LIKE thead-tdname,
v_tknum_tmp LIKE vttp-tknum,
v_formname TYPE rs38l_fnam,
v_venum TYPE vekp-venum,
v_screen, "Output on printer or screen
v_picked(1).
************************MAIN PROGRAM ***********************************
FORM entry USING return_code us_screen.
DATA: v_retcode TYPE sy-subrc.
CLEAR v_retcode.
Clear any previous data.
CLEAR wa_zpacklist.
v_screen = us_screen.
Check whether the Delivery number is already been picked.If it is
picked the set the print parameters
PERFORM processing USING us_screen
CHANGING v_retcode.
IF v_retcode NE 0.
return_code = 1.
ELSE.
return_code = 0.
ENDIF.
ENDFORM. "ENTRY
&----
*& Form PROCESSING
&----
Check whether the Delivery number is already been picked.If it is
picked the set the print parameters
----
FORM processing USING us_screen
CHANGING v_retcode.
DATA: v_fm_name TYPE rs38l_fnam.
DATA: v_control_param TYPE ssfctrlop.
DATA: v_composer_param TYPE ssfcompop.
DATA: v_recipient TYPE swotobjid.
DATA: v_sender TYPE swotobjid.
DATA: v_formname TYPE tdsfname .
get SmartForm from customizing table TNAPR
v_formname = tnapr-sform.
*
Check whether the delivery number has been picked.If it is picked
select the relevant data for that delivery number
PERFORM get_data CHANGING v_retcode.
CHECK v_retcode EQ 0.
Set the print parameters for Smartform
PERFORM set_print_param CHANGING v_control_param
v_composer_param
v_recipient
v_sender
v_retcode.
Check whether the Smart form exists.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = c_formname
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
fm_name = v_formname
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3
.
IF sy-subrc <> 0.
v_retcode = sy-subrc.
PERFORM protocol_update.
ENDIF.
Check the structure wa_zpacklist for data.
IF NOT wa_zpacklist IS INITIAL.
CALL FUNCTION v_formname
EXPORTING
archive_index = toa_dara
archive_parameters = arc_params
control_parameters = v_control_param
mail_recipient = v_recipient
mail_sender = v_sender
output_options = v_composer_param
user_settings = ' '
wa_zpacklist = wa_zpacklist
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO =
JOB_OUTPUT_OPTIONS =
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5. .
IF sy-subrc <> 0.
error handling
v_retcode = sy-subrc.
PERFORM protocol_update.
ENDIF.
ELSE.
IF v_screen = space.
CALL FUNCTION 'NAST_PROTOCOL_INIT_AND_LOAD'
EXPORTING
cps_nast = nast.
CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
EXPORTING
msg_arbgb = c_ZDEVMSG
msg_nr = c_000
msg_ty = c_E
msg_v1 = syst-msgv1
msg_v2 = syst-msgv2
msg_v3 = syst-msgv3
msg_v4 = syst-msgv4
EXCEPTIONS
OTHERS = 1.
ELSE.
MESSAGE e000 WITH 'No Data Exists, to Display Output'(002).
ENDIF. " IF v_screen = space.
ENDIF. " if not wa_zpacklist[] is initial
ENDFORM. " PROCESSING
&----
*& Form get_data
&----
Check whether the delivery number has been picked.If it is picked
select the relevant data for that delivery number
----
FORM get_data CHANGING v_retcode.
This is the Input obtained from the NAST entry, Delivery Number
wa_zpacklist-vbeln = nast-objky.
CLEAR v_picked.
Check if the Delivery has Not been Picked, if not then Do Not Display
the Layout and display an Error Message
CLEAR vbuk.
SELECT SINGLE kostk
FROM vbuk
INTO vbuk-kostk
WHERE vbeln EQ wa_zpacklist-vbeln.
The Picking should Not be Processed, Else Display a Msg
IF vbuk-kostk NE c_fully_picked AND vbuk-kostk NE space.
v_picked = c_X.
v_retcode = 1.
IF v_screen = space.
CALL FUNCTION 'NAST_PROTOCOL_INIT_AND_LOAD'
EXPORTING
cps_nast = nast.
CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
EXPORTING
msg_arbgb = c_ZDEVMSG
msg_nr = c_000
msg_ty = c_E
msg_v1 = syst-msgv1
msg_v2 = syst-msgv2
msg_v3 = syst-msgv3
msg_v4 = syst-msgv4
EXCEPTIONS
OTHERS = 1.
ELSE.
MESSAGE e000 WITH
'Delivery has not been Picked-Please Check'(001).
ENDIF.
ENDIF.
CHECK v_retcode = 0.
get all the header related data from LIKP,VBAK,VBFA,VTTP,VTTK
PERFORM get_header_data.
get the address numbers for shipping point ,ship-to-party and
sold-to-party from VBFA,TVST tables
PERFORM get_addr_no.
get all the item details from VBAP ,LIPS
PERFORM get_item_data.
ENDFORM. " get_data
&----
*& Form get_header_data
&----
Get all the header related data from LIKP,VBAK,VBFA,VTTP,VTTK
----
FORM get_header_data.
select the header data from LIKP based on Delivery number.
select the following fields and put it into workarea wa_zpacklist.
SELECT SINGLE vbeln "Delivery number
kunnr "Sold to party
kunag "Shipt to party
inco1 "Inco term
inco2 "Inco term 2
btgew "Total Weight
gewei "Net weight
anzpk "Total noumber of packages in delivery
vkorg "Sales Organization
vstel "Shipping Point/Receiving Point
bldat "Date on which the Docu. was created
FROM likp
INTO CORRESPONDING FIELDS OF wa_zpacklist
WHERE vbeln = wa_zpacklist-vbeln.
to get Purchase order number (BSTNK),
Sales order number (VBELV),
Contract number (VBELN_GRP),
Customer order date first get the Sales document from VBFA
using Delivery number (LIKP-VBELN) and VBTYP_N in the where clause.
YATHAM6 Del Begin - D47K910351 05/12/2004
SELECT SINGLE vbelv "Sales Document
INTO wa_zpacklist-vbelv
FROM vbfa
WHERE vbeln = wa_zpacklist-vbeln
AND vbtyp_n = c_posnn
YATHAM6 Insert Begin - 04/15/2004
Preceding Document category only Order need to be selected
Without this it is selecting Quote and/or Inquiry because of
Select single (Which would select the first entry)
AND vbtyp_v = c_vbtyp_v.
YATHAM6 Insert End - 04/15/2004
YATHAM6 Del End - D47K910351 05/12/2004
YATHAM6 Insert Begin - D47K910351 05/12/2004
When a Sales order is created with reference to another sales order
two precding document categorys will be available for a delivery.
Example: Order with subsequent delivery free of charge
Need to get latest preceding document. This change was made to pull
correct preceding document which will be on delivery line item.
All delivery items will have the same preceding document number.
select single vgbel from lips into wa_zpacklist-vbelv
where vbeln = wa_zpacklist-vbeln.
YATHAM6 Insert End - D47K910351 05/12/2004
SELECT SINGLE bstnk "Customer purchase order number
vbeln_grp "Master Contract NUmber
bstdk "Customer Order date
INTO (wa_zpacklist-bstnk,
wa_zpacklist-vbeln_grp,
wa_zpacklist-bstdk)
FROM vbak
WHERE vbeln = wa_zpacklist-vbelv.
select shipment number from VTTP table using wa_zpaclist-vbeln in the
where clause.
SELECT tknum "Shipment Number
FROM vttp
UP TO 1 ROWS
INTO wa_zpacklist-tknum_tmp
WHERE vbeln = wa_zpacklist-vbeln.
ENDSELECT.
for this value of wa_zpacklist-tknum_tmp select
External identification 2
Shipping type
Number of forwarding agent
from VTTK
SELECT SINGLE exti2 "External identification 2
vsart "Shipping type
tdlnr "Number of forwarding agent
INTO (wa_zpacklist-exti2,
wa_zpacklist-vsart,
wa_zpacklist-tdlnr)
FROM vttk
WHERE tknum = wa_zpacklist-tknum_tmp.
get the packing date from VEkP table for which Internal Handling
Unit Number(VENUM) is required from VEPO table.
get the value from VEPO table for the delivery number.
SELECT venum
UP TO 1 ROWS
FROM vepo
INTO v_venum
WHERE vbeln = wa_zpacklist-vbeln.
EXIT.
ENDSELECT.
CHECK sy-subrc = 0.
SELECT SINGLE erdat
FROM vekp
INTO wa_zpacklist-erdat
WHERE venum = v_venum.
ENDFORM. " get_header
&----
*& Form get_item
&----
Get all the item details from VBAP ,LIPS
----
FORM get_item_data.
refresh the internal tables of item data.
data: v_tabix like sy-tabix. "YATHAM6 Insert 03/31/2004
REFRESH : i_item,
i_item_lips.
get the item details from VBAP table based on the sales document
number(VBELV) and store the data in i_item
SELECT posnr "Sales Document Item
posex "Item Number of the Underlying Purchase
"Order
kwmeng "Quantity Ordered
kdmat "Customer Item Number
INTO CORRESPONDING FIELDS OF
TABLE i_item
FROM vbap
WHERE vbeln EQ wa_zpacklist-vbelv.
get the item details from LIPS based on Delivery number and
ZZCATNO(Catalog numer)from mara using an inner join between LIPS and
MARA using matnr as key
*Begin of GONAGUNTLA2 - @0001 02/11/2004 D47K906487
SELECT a~vbeln "Delivery Number
a~vtweg "Distribution Channel
a~posnr "Delivery item
a~lfimg "Actual quantity delivered (in sales units)
a~matnr "Material Number
b~zzcatno "Catlog Number for each material
FROM lips AS a
INNER JOIN
mara AS b
ON amatnr = bmatnr
INTO CORRESPONDING FIELDS OF
TABLE i_item_lips
WHERE a~vbeln = wa_zpacklist-vbeln.
SELECT a~vbeln "Delivery Number
a~vtweg "Distribution Channel
a~posnr "Delivery item
a~pstyv "Delivery item category
a~lfimg
"Actual quantity delivered (in sales units)
a~matnr "Material Number
a~uepos
"Higher-level item in bill of material structures
a~vgpos "Sales order line item
b~zzcatno "Catlog Number for each material
FROM lips AS a
INNER JOIN
mara AS b
ON amatnr = bmatnr
INTO CORRESPONDING FIELDS OF
TABLE i_item_lips
WHERE a~vbeln = wa_zpacklist-vbeln.
*End of GONAGUNTLA2 - @0001 02/11/2004 D47K906487
clear the workareas
CLEAR : wa_item,
wa_item_lips.
loop at the main internal table which contains the item data.
so that the data in the internal table i_item_lips is passed in the
i_item table
LOOP AT i_item INTO wa_item.
v_tabix = sy-tabix. "YATHAM6 Insert 03/31/2004
read the internal table i_item_lips for key Item Number(POSNR)
because the only link between the LIPS table and VBAP table is
(POSNR) for the same delivery number.
*Begin of GONAGUNTLA2 - @0001 02/12/2004
READ TABLE i_item_lips
INTO wa_item_lips
WITH KEY posnr = wa_item-posnr.
READ TABLE i_item_lips
INTO wa_item_lips
WITH KEY vgpos = wa_item-posnr.
*End of GONAGUNTLA2 - @0001 02/12/2004
check whether the same POSNR value is there in the I_item_lips table
IF sy-subrc = 0.
*Begin of GONAGUNTLA2 - @0001 02/12/2004
perform get_previous_del_qty using wa_zpacklist-vbelv
wa_item_lips-vgpos
wa_item_lips-vbeln
wa_item_lips-posnr
wa_item-kwmeng.
move wa_item-kwmeng to wa_item_lips-kwmeng.
*End of GONAGUNTLA2 - @0001 02/12/2004
to find out the Back Orders subtract Ordered Qty (KWMENG)
with Actual Qty (LFIMG)
*
wa_item_lips-zbkord = wa_item-kwmeng - wa_item_lips-lfimg.
Begin of Modifications - YATHAM6 12/15/2003
if wa_item-posex is not blank the repace wa_item-posnr with it.If *
it is not blank then don't do anything.
IF NOT wa_item-posex IS INITIAL.
*
MOVE wa_item-posex TO wa_item_lips-posnr .
*
ENDIF. "if not wa_item-posex is initial.
If wa_item-posex is initial.
Begin of GONAGUNTLA2 - @0001 02/12/2004
move wa_item-posnr to wa_item_lips-posex.
move wa_item_lips-posnr to wa_item_lips-posex.
*End of GONAGUNTLA2 - @0001 02/12/2004
else.
move wa_item-posex to wa_item_lips-posex.
endif.
End of Modifications - YATHAM6 12/15/2003
modify the internal table i_item by transporting VBELN LFIMG ZCALC.
*Begin of GONAGUNTLA2 - @0001 02/11/2004 D47K906487
MODIFY i_item FROM wa_item_lips
TRANSPORTING vbeln "Delivery Number
posnr "Delivery item
posex " YATHAM6 Insert
*lfimg "Actual Quantity Delivered
zbkord "Back Order
zzcatno "Catlog Number
matnr "Material Number
vtweg
WHERE posnr = wa_item-posnr.
MODIFY i_item FROM wa_item_lips "YATHAM6 Del 03/31/2004
MODIFY i_item FROM wa_item_lips index v_tabix
TRANSPORTING vbeln "Delivery Number
posnr "Delivery item
posex " YATHAM6 Insert
KWMENG
" gonaguntla2 Insert
lfimg
"Actual Quantity Delivered
zbkord "Back Order
zzcatno "Catlog Number
matnr "Material Number
vtweg
uepos
pstyv.
*Table i_item should be updated with the corresponding entry not with
*the
item number.
WHERE posnr = wa_item-posnr. "YATHAM6 Del
else.
YATHAM6 Mod Begin - 04/22/2004
Delete the Current row instead of item. Because the Delivery item
sequence could be different than that of the Sales Order item #.
delete i_item where posnr = wa_item-posnr.
delete i_item index v_tabix.
YATHAM6 Mod End - 04/22/2004
*End of GONAGUNTLA2 - @0001 02/11/2004 D47K906487
ENDIF. " if sy-subrc = 0.
ENDLOOP. "loop at i_item
now once the i_item internal table is full
check it.
IF NOT i_item[] IS INITIAL.
sort i_item[] by vbeln descending posex. "YATHAM6 Insert
move the data from i_item into the structure wa_zpacklist.
wa_zpacklist-zitempack_tb[] = i_item[].
ENDIF. "if not i_item[] is initial.
ENDFORM. " get_item
&----
*& Form get_addr
&----
text
----
Get the address numbers for shipping point ,ship-to-party and
sold-to-party from VBFA,TVST tables
----
FORM get_addr_no .
To find out the addresses of sold-to-party, goto table VBPA select
the address number ADRNR
SELECT SINGLE adrnr "Address Number
INTO wa_zpacklist-adrnrstp
FROM vbpa
YATHAM6 Mod Begin - 04/15/2004
Get the address numbers for the Delivery instead of Sales order
WHERE vbeln = wa_zpacklist-vbelv
WHERE vbeln = wa_zpacklist-vbeln
YATHAM6 Mod End - 04/15/2004
AND parvw = c_parvw_stp.
To find out the addresses of ship-to-party, goto table VBPA select
the address number ADRNR
SELECT SINGLE adrnr "Address Number
INTO wa_zpacklist-adrnrshp
FROM vbpa
YATHAM6 Mod Begin - 04/15/2004
Get the address numbers for the Delivery instead of Sales order
WHERE vbeln = wa_zpacklist-vbelv
WHERE vbeln = wa_zpacklist-vbeln
YATHAM6 Mod End - 04/15/2004
AND parvw = c_parvw_shp.
.
To select the addresses for Shipping point find out the address *
number from TVST table .
SELECT SINGLE adrnr "Address Number
INTO wa_zpacklist-adrnr
FROM tvst
WHERE vstel = wa_zpacklist-vstel.
ENDFORM. " get_addr
&----
*& Form set_print_param
&----
Set the print paramters for the smartform
----
FORM set_print_param CHANGING v_control_param TYPE ssfctrlop
v_composer_param TYPE ssfcompop
v_recipient TYPE swotobjid
v_sender TYPE swotobjid
v_retcode TYPE sy-subrc.
DATA: v_itcpo TYPE itcpo.
DATA: v_repid TYPE sy-repid.
DATA: v_device TYPE tddevice.
v_repid = sy-repid.
CALL FUNCTION 'WFMC_PREPARE_SMART_FORM'
EXPORTING
pi_nast = nast
pi_repid = v_repid
IMPORTING
pe_returncode = v_retcode
pe_itcpo = v_itcpo
pe_device = v_device
pe_recipient = v_recipient
pe_sender = v_sender.
IF v_retcode = 0.
MOVE-CORRESPONDING v_itcpo TO v_composer_param.
v_control_param-device = v_device.
v_control_param-no_dialog = c_X.
v_control_param-preview = v_screen.
v_control_param-getotf = v_itcpo-tdgetotf.
v_control_param-langu = nast-spras.
ENDIF.
ENDFORM. " set_print_param
&----
*& Form protocol_update
&----
text
----
Error Handling
----
FORM protocol_update .
CHECK v_screen = space.
CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
EXPORTING
msg_arbgb = syst-msgid
msg_nr = syst-msgno
msg_ty = syst-msgty
msg_v1 = syst-msgv1
msg_v2 = syst-msgv2
msg_v3 = syst-msgv3
msg_v4 = syst-msgv4
EXCEPTIONS
OTHERS = 1.
ENDFORM. " protocol_update
&----
*& Form get_previous_del_qty
&----
text
----
--> p1 text
<-- p2 text
----
FORM get_previous_del_qty using f_so
f_so_item
f_del
f_del_item
f_so_qty.
data: begin of i_vbfa_tab occurs 0,
vbeln like vbfa-vbeln,
posnn like vbfa-posnn,
end of i_vbfa_tab.
data: fv_lfimg like lips-lfimg.
select vbeln posnn into table i_vbfa_tab from vbfa
where vbelv eq f_so
and posnv eq f_so_item
and vbtyp_n eq 'J'.
loop at i_vbfa_tab.
if i_vbfa_tab-vbeln ne f_del.
clear fv_lfimg.
select single lfimg into fv_lfimg
from lips
where vbeln eq i_vbfa_tab-vbeln
and posnr eq i_vbfa_tab-posnn.
f_so_qty = f_so_qty - fv_lfimg.
endif.
endloop.
ENDFORM. " get_previous_del_qty
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes you cant configure the smartform for picking list . This will be configured in OMNU transaction. If you want to have smartform Then you can canfigure for sapscript but internally call samrtform FM. It will serve your purpose.
Reward points if useful.
Regards,
Nageswar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I was once develop a Transfer Order Pick List. The standard T-Code is LT31. But it still use SAPScript and no Smartform could be used since the configuration can't accept smartform name. The standard SAPScript is LVSTALISTE.
Regards,
Teddy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.