Script Print Program Logic.......
Hi All
This is the print program of my script, i am not getting the logic..can any body help me with this..
INCLUDE rvadtabl.
TABLES: vbuk, "Vertriebsbeleg (Kopf)-Status
vbco3, "Schlüsselfelder Vertriebsbeleg
vbpla, "Allgemeine Transportdaten
vbplk, "Versandelement Kopfdaten
vbplp, "Versandelement Positionsdaten
vbpls, "Verpackung Summendaten
vekp,
adrc,
vbfa. "DEVK937590
TABLES: vbkd. "DEVK942078
*DEVK9A0EB4 - Add define
TYPES:
ty_itcsy TYPE STANDARD TABLE OF itcsy.
start of change for DEVK937590
DATA: BEGIN OF t_deliveryflow OCCURS 0, "VBFA delivery flow
vbeln LIKE vbfa-vbeln, "Subsequent sales and distribu
END OF t_deliveryflow.
DATA: v_lin TYPE i.
CONSTANTS: c_x(1) TYPE c VALUE 'X'.
end of change for DEVK937590
DATA: BEGIN OF xvbplk OCCURS 10.
INCLUDE STRUCTURE vbplk.
DATA: END OF xvbplk.
DATA : BEGIN OF vbdkl OCCURS 10.
INCLUDE STRUCTURE vbdkl.
DATA : END OF vbdkl.
DATA: BEGIN OF tvbdpl OCCURS 0. "Internal table for items
INCLUDE STRUCTURE vbdpl.
DATA: END OF tvbdpl.
DATA: BEGIN OF xvbplp OCCURS 50.
INCLUDE STRUCTURE vbplp.
DATA: END OF xvbplp.
DATA: BEGIN OF xvbpls OCCURS 10.
INCLUDE STRUCTURE vbpls.
DATA: END OF xvbpls.
DATA: retcode LIKE sy-subrc.
DATA: xscreen(1) TYPE c. "Ausgabe auf Drucker oder Bildschirm
DATA: t_vepo LIKE vepo OCCURS 0 WITH HEADER LINE, "VEPO internal table
BEGIN OF t_cartons OCCURS 0, "Internal table for cartons
venum LIKE vepo-venum, "Shipping unit # for carton
END OF t_cartons,
BEGIN OF t_boxes OCCURS 0, "Internal table for BOXES
venum LIKE vepo-venum, "Shipping unit # for BOXES
laeng LIKE vekp-laeng,
breit LIKE vekp-breit,
hoehe LIKE vekp-hoehe,
meabm LIKE vekp-meabm,
END OF t_boxes,
BEGIN OF t_pack_dim OCCURS 0,
laeng LIKE vekp-laeng,
breit LIKE vekp-breit,
hoehe LIKE vekp-hoehe,
meabm LIKE vekp-meabm,
box_qty TYPE i,
END OF t_pack_dim,
v_venum LIKE vepo-venum, "Shipping unit number
i_cartons TYPE i, "# of cartons (Integer type)
i_boxes TYPE i, "# of boxes (Integer type)
i_box_count TYPE i, "# of boxes/carton "DEVK926768
c_cartons(4) TYPE c, "# of cartons (Character type)
c_boxes(4) TYPE c, "# of boxes (Character type)
c_bolnr(35) TYPE c,
v_tel_number LIKE adrc-tel_number,
v_adrnr LIKE adrc-addrnumber,
v_kdmat LIKE lips-kdmat,
v_btgew LIKE likp-btgew,
v_gewei LIKE likp-gewei,
v_arktx LIKE lips-arktx.
******DEVK9A0IK7 Addition by RAMARAJG Starts here
types : BEGIN OF t_item ,
posnr1 type vbplp-posnr,
material1 TYPE mara-matnr,
brgew1 type vbplp-brgew,
vemeh1 type vbplp-vemeh,
item_weight1 TYPE n,
arktx1 type vbplp-arktx,
vboxcnt type n,
end of t_item.
*types : BEGIN OF t_item1 ,
posnr1 type vbplp-posnr,
material1 TYPE mara-matnr,
vemng1 type vbplp-brgew,
vemeh1 type vbplp-vemeh,
item_weight1 TYPE n,
arktx1 type vbplp-arktx,
v_boxcnt type n,
end of t_item1.
DATA: it_item TYPE TABLE OF t_item,
wa_item TYPE t_item.
data: it_item1 type table of t_item,
wa_item1 type t_item.
*data: wa_itab1 like itab1.
data: v_grwt type lips-brgew, "Gross Weight in KG
v_gunit type likp-gewei, "Gross Weight Unit
v_netwt type lips-ntgew, "Net Weight
v_unit type likp-gewei. "Net Weight Unit
v_tboxes type i,
******DEVK9A0IK7 Addition by RAMARAJG ends here
A. Nachricht (allgemein) *
FORM entry USING return_code us_screen.
CLEAR retcode.
xscreen = us_screen.
PERFORM processing USING us_screen.
IF retcode NE 0.
return_code = 1.
ELSE.
return_code = 0.
ENDIF.
ENDFORM. "entry
FORM PROCESSING *
--> PROC_SCREEN *
FORM processing USING proc_screen.
PERFORM get_data. " <-- speziell
PERFORM form_open USING proc_screen vbpla-land1.
CHECK retcode = 0.
PERFORM shipping_point_tel_no.
PERFORM boxes_and_cartons.
PERFORM gross_weight.
***********DEVK9A0IK7 starts here
*******Perform to get the Net weight
*******Perform to get Total weight for each line item
Perform net_weight. "DEVK9A0IK7
Perform Total_weight. "DEVK9A0IK7
***********DEVK9A0IK7 ends here
PERFORM bill_of_lading.
CHECK retcode = 0.
PERFORM check_repeat.
PERFORM text_print. " <-- speziell
begin shb
PERFORM get_end_customer_po.
*end shb
PERFORM packing_dimensions.
PERFORM remarks.
CHECK retcode = 0.
PERFORM form_close.
CHECK retcode = 0.
ENDFORM. "processing
FORM FORM_OPEN *
--> US_SCREEN *
--> US_COUNTRY *
FORM form_open USING us_screen us_country.
INCLUDE rvadopfo.
ENDFORM. "form_open
FORM FORM_CLOSE *
FORM form_close.
CALL FUNCTION 'CLOSE_FORM' "...Ende Formulardruck
EXCEPTIONS OTHERS = 1.
IF sy-subrc NE 0.
retcode = 1.
PERFORM protocol_update.
ENDIF.
SET COUNTRY space.
ENDFORM. "form_close
FORM CHECK_REPEAT *
FORM check_repeat.
SELECT * INTO *nast FROM nast WHERE kappl = nast-kappl
AND objky = nast-objky
AND kschl = nast-kschl
AND spras = nast-spras
AND parnr = nast-parnr
AND parvw = nast-parvw
AND nacha BETWEEN '1' AND '4'.
CHECK *nast-vstat = '1'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'REPEAT'
window = 'REPEAT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
EXIT.
ENDSELECT.
ENDFORM. "check_repeat
FORM PROTOCOL_UPDATE *
FORM protocol_update.
CHECK xscreen = 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
B. Packliste (speziell) *
Die Verpackung von Lieferungen wird durch Versandelemente (VSE)
realisiert. Technisch ist ein Versandelement ein Beleg mit Kopf-
und Positionsdaten (Strukturen VBPLK/XVBPLK und VBPLP/XVBPLP).
Eine Position in einem VSE ist entweder wieder ein VSE oder Teil
eine Lieferposition (also mit den zum VSE gehörenden Materialen/
Versandhilftsmitteln verpackt). Der Zusammenhang zur Lieferung
wird durch die beiden Felder VBELN (Lieferung) und POSNR (Position)
in der Struktur VBPLP realisiert. Es ist zu beachten, daß ein VSE
keine Positionsdaten enthalten muß: Die Lieferung wurde dann nicht
vollständig verpackt.
Mathematisch gesehen stellen die VSE einen Wald (aus Bäumen) dar.
An den Knoten können noch Lieferpositionsdaten hängen. Um zu
erkennen ob ein Knoten eine Wurzel oder (und) ein Blatt ist, gibt
es im VSE-Kopf Kennzeichen. Ist KZOBE gesetzt, so ist das VSE ein
oberes Element, also eine Wurzel. Ist KZUNT gesetzt, stellt das VSE
ein unteres Element dar, also ein Blatt. Ist keines der beiden
Kennzeichen gesetzt dann ist das VSE ein innerer Knoten. Es ist
zu beachten, daß beiden Kennzeichen gesetzt sein können: Der Baum
besteht aus einem Knoten. Die Tiefe eines Knotens durch das Feld
TIVEL gegeben.
Weiterhin ist der Baum doppelt verkettet. Es ist also möglich,
nicht nur einen Weg von der Wurzel (eines Teilbaums) zu einem
Blatt zu finden, sondern auch umgekehrt von einem Blatt zur Wurzel
zu gelangen. Dazu existiert (im VSE-Kopf) das Feld UEVEL, also
das übergeordnete VSE.
Um schließlich zu entscheiden, ob ein VSE-Position ein VSE oder
eine Lieferposition ist, wird das Feld POSNR ausgewertet. Ist
das Feld initial, stellt die Position ein VSE dar, im anderen Fall
enthält es die Lieferposition. Ist die Position ein VSE, steht im
Feld UNVEL das zugehörige untergeordnete VSE.
FORM get_data.
vbco3-vbeln = nast-objky.
vbco3-spras = nast-spras.
vbco3-kunde = nast-parnr.
vbco3-parvw = nast-parvw.
*mod+
CALL FUNCTION 'RV_DELIVERY_PRINT_VIEW'
EXPORTING
comwa = vbco3
IMPORTING
kopf = vbdkl
TABLES
pos = tvbdpl.
CALL FUNCTION 'SD_PACKING_PRINT_VIEW'
EXPORTING
comwa = vbco3
IMPORTING
vbpla_wa = vbpla
TABLES
vbplk_tab = xvbplk
vbplp_tab = xvbplp
vbpls_tab = xvbpls
EXCEPTIONS
OTHERS = 01.
LOOP AT xvbplk WHERE kzobe = 'X'.
EXIT.
ENDLOOP.
IF sy-subrc > 0.
syst-msgid = 'VL'.
syst-msgno = '490'.
syst-msgty = 'E'.
PERFORM protocol_update.
retcode = 1.
ENDIF.
ENDFORM. "get_data
FORM TEXT_PRINT *
FORM text_print.
Die Kopfdaten werden implizit ausgegeben, ...
... dann die Überschriften der Positionen ...
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'HEADER'
type = 'TOP'.
... und schließlich die Positionen ausgeben ...
LOOP AT xvbplk WHERE kzobe = 'X'.
PERFORM packing_tree USING xvbplk-venum.
ENDLOOP.
ENDFORM. "text_print
Rekursive Prozedur
FORM packing_tree USING value(shenr).
Daten des Versandelements shenr ausgeben, also Wurzel des Teilbaums
MOVE space TO xvbplk.
xvbplk-venum = shenr.
READ TABLE xvbplk.
vbplk = xvbplk.
READ TABLE t_cartons WITH KEY venum = vbplk-venum.
IF sy-subrc = 0.
IF vbplk-brgew <> 0.
PERFORM set_textsymbol USING '&CARTON_WEIGHT&'
vbplk-brgew.
ELSE.
PERFORM set_textsymbol USING '&CARTON_WEIGHT&'
ENDIF.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'SHELEM'.
ENDIF.
Nun die Positionen abarbeiten (Teilbäume durchlaufen).
Hier wäre eventuell ein Sortierung zwischen Lieferpositionen
und weiteren Versandelementen sinnvoll. Alle nachgeordneten
Positionen liegen eine Stufe tiefer.
LOOP AT xvbplp WHERE venum = shenr.
IF xvbplp-posnr IS INITIAL.
Versandelement
PERFORM packing_tree USING xvbplp-unvel.
ELSE.
Lieferposition (Anteil)
vbplp = xvbplp.
PERFORM customer_material.
***ramarajg starts.
perform item_list.
***ramarajg end.
IF vbplp-brgew <> 0.
PERFORM set_textsymbol USING '&ITEM_WEIGHT&'
vbplp-brgew.
ELSE.
PERFORM set_textsymbol USING '&ITEM_WEIGHT&'
ENDIF.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'DELPOS'.
ENDIF.
ENDLOOP.
***ramarajg starts.
perform TOTAL_WEIGHT.
loop at it_item into wa_item.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEMPOS'.
endloop.
break ramarajg.
***ramarajg end.
ENDFORM. "packing_tree
FORM SET_TEXTSYMBOL *
FORM set_textsymbol USING text_symbol
text_value.
CALL FUNCTION 'TEXT_SYMBOL_SETVALUE'
EXPORTING
name = text_symbol
value = text_value.
ENDFORM. "set_textsymbol
*& Form BOXES_AND_CARTONS
text
--> p1 text
<-- p2 text
FORM boxes_and_cartons.
CLEAR: t_cartons,
t_boxes,
i_cartons,
i_boxes.
REFRESH: t_cartons,
t_boxes.
start of change for DEVK937590
CLEAR t_deliveryflow[].
SELECT vbeln
FROM vbfa
INTO CORRESPONDING FIELDS OF TABLE t_deliveryflow
WHERE vbelv = vbpla-vbeln AND vbtyp_n = c_x.
Select data
DESCRIBE TABLE t_deliveryflow LINES v_lin.
CHECK v_lin GT 0.
SELECT venum vbeln
FROM vepo
INTO CORRESPONDING FIELDS OF TABLE t_vepo
FOR ALL ENTRIES IN t_deliveryflow
WHERE venum = t_deliveryflow-vbeln.
SELECT VENUM
VBELN
FROM VEPO
INTO CORRESPONDING FIELDS OF TABLE T_VEPO
WHERE VBELN = VBPLA-VBELN.
end of change for DEVK937590
SORT t_vepo BY venum.
DELETE ADJACENT DUPLICATES FROM t_vepo COMPARING venum.
Determine the number of cartons and boxes to be shipped.
To determine the number of cartons, shipping unit number (VENUM) is
checked if it a lower-level shipping unit. This is done by reading
table VEPO and checking if VENUM exist in UNVEL (Lower-level shipping
unit). If it does, this means that VENUM is contained within
another container. If it does not exist, it is considered the highest
level of packing for that specific delivery.
LOOP AT t_vepo.
check if VENUM is a lower level shipping unit.
SELECT SINGLE venum INTO v_venum
FROM vepo
WHERE unvel = t_vepo-venum.
If shipping unit number is found, count as carton.
IF sy-subrc = 0.
check if carton already exist for the carton.
READ TABLE t_cartons WITH KEY venum = v_venum.
if carton does not exist, append table
IF sy-subrc <> 0.
t_cartons-venum = v_venum.
APPEND t_cartons.
ENDIF.
ENDIF.
ENDLOOP.
count boxes and cartons
DESCRIBE TABLE t_vepo LINES i_boxes.
DESCRIBE TABLE t_cartons LINES i_cartons.
Convert cartons and boxes field values to CHARACTER type FORMAT.
In order to save the output values to the output fields, the
fields are converted to CHARACTER type formats.
MOVE: i_cartons TO c_cartons,
i_boxes TO c_boxes.
PERFORM set_textsymbol USING '&BOXES&'
c_boxes.
PERFORM set_textsymbol USING '&CARTONS&'
c_cartons.
ENDFORM. " BOXES_AND_CARTONS
*& Form BILL_OF_LADING
text
--> p1 text
<-- p2 text
FORM bill_of_lading.
SELECT SINGLE bolnr
FROM likp
INTO c_bolnr
WHERE vbeln = vbpla-vbeln.
PERFORM set_textsymbol USING '&BILL_OF_LADING&'
c_bolnr.
ENDFORM. " BILL_OF_LADING
*& Form PACKING_DIMENSIONS
text
--> p1 text
<-- p2 text
FORM packing_dimensions.
CLEAR: T_BOXES,
T_PACK_DIM.
REFRESH: T_BOXES,
T_PACK_DIM.
SELECT VENUM
LAENG
BREIT
HOEHE
MEABM
FROM VEKP
INTO CORRESPONDING FIELDS OF TABLE T_BOXES
FOR ALL ENTRIES IN T_VEPO
WHERE VENUM = T_VEPO-VENUM.
LOOP AT T_BOXES.
READ TABLE T_PACK_DIM WITH KEY LAENG = T_BOXES-LAENG
BREIT = T_BOXES-BREIT
HOEHE = T_BOXES-HOEHE
MEABM = T_BOXES-MEABM.
IF SY-SUBRC = 0.
T_PACK_DIM-BOX_QTY = T_PACK_DIM-BOX_QTY + 1.
MODIFY T_PACK_DIM INDEX SY-TABIX.
ELSE.
T_PACK_DIM-LAENG = T_BOXES-LAENG.
T_PACK_DIM-BREIT = T_BOXES-BREIT.
T_PACK_DIM-HOEHE = T_BOXES-HOEHE.
T_PACK_DIM-MEABM = T_BOXES-MEABM.
T_PACK_DIM-BOX_QTY = 1.
APPEND T_PACK_DIM.
ENDIF.
ENDLOOP.
LOOP AT T_PACK_DIM.
AT FIRST.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'PACKING_DIMENSIONS_HEADER'.
ENDAT.
CLEAR: VEKP,
C_BOXES.
VEKP-LAENG = T_PACK_DIM-LAENG.
VEKP-BREIT = T_PACK_DIM-BREIT.
VEKP-HOEHE = T_PACK_DIM-HOEHE.
VEKP-MEABM = T_PACK_DIM-MEABM.
MOVE: T_PACK_DIM-BOX_QTY TO C_BOXES.
PERFORM SET_TEXTSYMBOL USING '&BOX_QTY&'
C_BOXES.
IF VEKP-LAENG <> 0 AND
VEKP-BREIT <> 0 AND
VEKP-HOEHE <> 0.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'PACKING_DIMENSIONS'.
ENDIF.
ENDLOOP.
ENDFORM. " PACKING_DIMENSIONS
*& Form REMARKS
text
--> p1 text
<-- p2 text
FORM remarks.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'REMARKS'.
ENDFORM. " REMARKS
*& Form SHIPPING_POINT_TEL_NO
text
--> p1 text
<-- p2 text
FORM shipping_point_tel_no.
SELECT SINGLE adrnr
FROM tvst
INTO v_adrnr
WHERE vstel = vbpla-vstel.
SELECT SINGLE tel_number
FROM adrc
INTO adrc-tel_number
WHERE addrnumber = v_adrnr.
ENDFORM. " SHIPPING_POINT_TEL_NO
*& Form CUSTOMER_MATERIAL
text
--> p1 text
<-- p2 text
FORM customer_material.
CLEAR: v_kdmat.
begin of mod*
IF vbdkl-lfart = 'LO'.
SELECT SINGLE kdmat postx
INTO (v_kdmat , v_arktx)
FROM knmt
WHERE vkorg = vbdkl-vkorg
AND vtweg = '01'
AND kunnr = vbdkl-kunag
AND matnr = vbplp-matnr.
IF NOT v_kdmat IS INITIAL.
vbplp-matnr = v_kdmat.
vbplp-arktx = v_arktx.
ENDIF.
ELSE.
SELECT SINGLE kdmat
FROM lips
INTO v_kdmat
WHERE vbeln = vbplp-vbeln AND
posnr = vbplp-posnr AND
matnr = vbplp-matnr.
ENDIF.
**ramarajg
IF v_kdmat <> ' '.
PERFORM set_textsymbol USING '&MATERIAL&'
v_kdmat.
ELSE.
PERFORM set_textsymbol USING '&MATERIAL&'
vbplp-matnr.
ENDIF.
ENDFORM. " CUSTOMER_MATERIAL
FORM ITEM_WEIGHTS *
--> IN_TAB4 *
--> OUT_TAB4 *
FORM item_weights TABLES in_tab4 STRUCTURE itcsy
out_tab4 STRUCTURE itcsy.
DATA: n_vbeln(10) TYPE n,
v_btgew LIKE likp-btgew,
v_ntgew1 LIKE vekp-ntgew,
v_btgew1 LIKE likp-btgew,
v_ntgew2 LIKE likp-ntgew,
v_btgew2 LIKE likp-btgew,
BEGIN OF t_venum OCCURS 0,
venum LIKE vepo-venum,
END OF t_venum.
READ TABLE in_tab4 INDEX 1.
CHECK sy-subrc = 0.
MOVE in_tab4-value TO n_vbeln. "convert to numeric type.
start of change for DEVK937590
*break ramarajg.
CLEAR t_deliveryflow[].
SELECT vbeln
FROM vbfa
INTO CORRESPONDING FIELDS OF TABLE t_deliveryflow
WHERE vbelv = n_vbeln AND vbtyp_n = c_x.
Select data
DESCRIBE TABLE t_deliveryflow LINES v_lin.
CHECK v_lin GT 0.
SELECT venum
FROM vepo
INTO CORRESPONDING FIELDS OF TABLE t_venum
FOR ALL ENTRIES IN t_deliveryflow
WHERE venum = t_deliveryflow-vbeln.
SELECT VENUM
FROM VEPO
INTO CORRESPONDING FIELDS OF TABLE T_VENUM
WHERE VBELN = N_VBELN.
end of change for DEVK937590
CLEAR v_btgew.
DESCRIBE TABLE t_venum LINES v_lin. "DEVK937590
CHECK v_lin GT 0. "DEVK937590
SELECT ntgew
FROM vekp
INTO v_btgew
FOR ALL ENTRIES IN t_venum
WHERE venum = t_venum-venum.
v_btgew1 = v_btgew1 + v_btgew.
ENDSELECT.
SELECT SUM( ntgew )
FROM lips
INTO v_ntgew1
WHERE vbeln = n_vbeln.
SELECT SINGLE ntgew
btgew
FROM likp
INTO (v_ntgew2, v_btgew2)
WHERE vbeln = n_vbeln.
IF v_ntgew1 = v_ntgew2 AND
v_btgew1 = v_btgew2.
READ TABLE out_tab4 WITH KEY name = 'PRINT_WEIGHT'.
IF sy-subrc = 0 .
out_tab4-value = 'X'.
ELSE.
out_tab4-value = ' '.
ENDIF.
MODIFY out_tab4 INDEX sy-tabix.
ENDIF.
ENDFORM. "item_weights
*& Form GROSS_WEIGHT
text
--> p1 text
<-- p2 text
FORM gross_weight.
CLEAR: v_btgew.
SELECT SINGLE btgew
gewei
FROM likp
INTO (v_btgew, v_gewei)
WHERE vbeln = vbpla-vbeln.
PERFORM set_textsymbol USING '&GROSS_WEIGHT&'
v_btgew.
PERFORM set_textsymbol USING '&GROSS_WEIGHT_UNIT&'
v_gewei.
changes added by RAMARAJG starts here
clear v_grwt.
clear v_gunit.
v_grwt = v_btgew.
v_gunit = v_gewei.
if v_gunit = 'G'.
v_grwt = v_grwt / 1000.
v_gunit = 'KG'.
endif.
PERFORM set_textsymbol USING '&GROSS_WEIGHT1&'
v_grwt.
PERFORM set_textsymbol USING '&GROSS_WEIGHT_UNIT1&'
v_gunit.
changes added by RAMARAJG ends here
ENDFORM. " GROSS_WEIGHT
*& Form GET_END_CUSTOMER_PO
Retrieve End Customer PO#
--> p1 text
<-- p2 text
FORM get_end_customer_po.
DATA: v_zvgbel LIKE lips-vgbel.
DATA v_bstkd_e TYPE bstkd_e.
CLEAR: v_bstkd_e, v_zvgbel.
SELECT SINGLE vgbel INTO v_zvgbel
FROM lips
WHERE vbeln = vbpla-vbeln.
SELECT SINGLE bstkd_e INTO v_bstkd_e
FROM vbkd
WHERE vbeln = v_zvgbel
AND bstkd_e > ''.
PERFORM set_textsymbol USING '&V_BSTKD_E&'
v_bstkd_e.
ENDFORM. " GET_END_CUSTOMER_PO
*DEVK9A0EB4 - Add a form
*& Form shipper_acct
Get shipper account at customer
FORM shipper_acct TABLES in_tab1 TYPE ty_itcsy
out_tab1 TYPE ty_itcsy.
DATA: v_kunag TYPE likp-kunag, " Sold to party
v_eikto TYPE knvv-eikto. "Shipper account number at customer
DATA v_strlen(10) TYPE c.
DATA wa_tab1 TYPE itcsy.
DATA n_vbeln(10) TYPE n.
Get kunnr from likp
CLEAR wa_tab1.
READ TABLE in_tab1 INTO wa_tab1 WITH KEY name = 'VBPLA-VBELN'.
IF sy-subrc = 0.
n_vbeln = vbpla-vbeln.
ENDIF.
CHECK sy-subrc = 0.
SELECT kunag
FROM likp
INTO v_kunag
WHERE vbeln = n_vbeln.
ENDSELECT.
IF sy-subrc = 0.
Get shipper account
SELECT eikto INTO v_eikto
FROM knvv
WHERE kunnr = v_kunag.
ENDSELECT.
IF sy-subrc = 0.
*append the field to the out_tab1 printing output
wa_tab1-name = 'VKNN-EIKTO'.
wa_tab1-value = v_eikto.
APPEND wa_tab1 TO out_tab1.
ENDIF.
ENDIF.
ENDFORM. "shipper_acct
***********DEVK9A0IK7 starts here
*& Form net_weight
text
--> p1 text
<-- p2 text
form net_weight .
CLEAR: v_btgew.
SELECT SINGLE ntgew
gewei
FROM likp
INTO (v_netwt, v_unit)
WHERE vbeln = vbpla-vbeln.
if v_unit = 'G'.
v_netwt = v_netwt / 1000.
v_unit = 'KG'.
endif.
PERFORM set_textsymbol USING '&NET_WEIGHT&'
v_netwt.
PERFORM set_textsymbol USING '&NET_WEIGHT_UNIT&'
v_unit.
endform. " net_weight
***********DEVK9A0IK7 ends here
*& Form item_list
text
--> p1 text
<-- p2 text
form item_list.
move vbplp-posnr to wa_item-posnr1.
*move material to wa_itab1-material1.
move vbplp-brgew to wa_item-brgew1.
move vbplp-vemeh to wa_item-vemeh1.
*move item_weight to wa_itab1-item_weight1.
*move gross_weight_unit to wa_itab1-gross_weight_unit1.
move v_arktx to wa_item-arktx1.
if v_kdmat <> ' '.
move v_kdmat to wa_item-material1.
else.
move vbplp-matnr to wa_item-material1.
endif.
wa_item-vboxcnt = 1.
append wa_item TO it_item.
CLEAR : wa_item1, wa_item.
it_item1[] = it_item[].
REFRESH it_item[].
break-point.
endform. " item_list
*& Form TOTAL_WEIGHT
text
--> p1 text
<-- p2 text
form TOTAL_WEIGHT .
LOOP AT it_item1 into wa_item1.
READ TABLE it_item INTO wa_item WITH KEY material1 = wa_item1-material1 posnr1 = wa_item1-posnr1.
IF sy-subrc NE 0.
APPEND wa_item1 TO it_item.
ELSE.
wa_item1-brgew1 = wa_item1-brgew1 + wa_item-brgew1.
Wa_item1-vboxcnt = wa_item1-vboxcnt + wa_item-vboxcnt.
MODIFY it_item FROM wa_item1 TRANSPORTING brgew1 vboxcnt
WHERE material1 = wa_item1-material1
AND posnr1 = wa_item1-posnr1.
ENDIF.
ENDLOOP.
endform. " TOTAL_WEIGHT
the Logic to be added is this
b. Remove the carton ID & box ID from the print out, the line item should just print the total delivery quantity, do not split the printing by different box ID or carton ID.
i. Delivery Item= LIPS-POSNR
ii. Delivery Qty for Item = LIPSD-G_LFIMG= LIPSD-PIKMG
c. Add Total Boxes for each item, this should be a calculation field for each material HUMV4-MATNR, count how many handling unit VEKPVB-EXIDV has been used to pack the same material , output the total boxes for each delivery item.
d. Add Gross Weight for each item , retrieve data from LIPS-BRGEW
e. Add Net weight to the print out, below the gross weight retrieve data from LIKP-NTGEW
Similar Messages
-
List of standard sap scripts/print programs in SAP MM and SD modules ??
Hi,
I have worked in medruck only. Can anyone give me a list of other standard sap scripts/print program names in SAP MM, FI/CO and SD modules, which often needs to be modified by the client ?
thankspress f4 in SE71
then press application heirarchy, expand the modules which ever u want.
regards.
santhosh reddy
Reward if useful -
Problems with SAP Script print program
Hi,
I have the following scenario:
I have a workflow which prints a sapscript with data stored in the workflow container.
The workflow method 'executeform' populates a selection table and submits it to the print program using:
SUBMIT ZPRINT_FORM WITH SELECTION-TABLE sel_table
This print program then populates the form with data and calls the OPEN_FORM/WRITE_FORM/CLOSE_FORM FM's.
My problem is that some of the variables in the workflow container are CHAR255, when these get moved to the selection table (seltab-low) they get truncated as seltab-low is a CHAR45. Is there a way round this??
This is the first time I have used sapscript, I notice that the variables printed on the form correspond to the parameters defined in the Print Program. I assume therefore that this is why the
SUBMIT ZPRINT_FORM WITH SELECTION-TABLE sel_table
has been used and why the OPEN_FORM/WRITE_FORM/CLOSE_FORM was not coded directly in the workflow executeform method.
Any guidance on how to proceed with this would be appreciated.
Many Thanks,
PaulHi Paul,
In general, in the statement
SUBMIT ZPRINT_FORM WITH SELECTION-TABLE sel_table.
sel_table is an internal table with the structure RSPARAMS.
This variant allows you to set the names and contents of the parameters and selection options dynamically at runtime.
You can use the function module RS_REFRESH_FROM_SELECTOPTIONS to read the contents of the parameters and selection options of the current program into an internal table seltab with the structure RSPARAMS. By using SUBMIT ... WITH SELECTION-TABLE seltab, you can then pass these values on directly.
The work around for the variables that cannot be passed using the submit statement, can be exported to Global memory ids and the same can be retrieved in the print progra.
The syntax for the export and import statements is something like this.
TABLES INDX.
TYPES: BEGIN OF ITAB3_TYPE,
CONT(4),
END OF ITAB3_TYPE.
DATA: INDXKEY LIKE INDX-SRTFD VALUE 'KEYVALUE',
F1(4), F2 TYPE P,
ITAB3 TYPE STANDARD TABLE OF ITAB3_TYPE WITH NON-UNIQUE
DEFAULT KEY INITIAL SIZE 2,
WA_INDX TYPE INDX.
Fill the data fields before CLUSTR
before the actual export
INDX-AEDAT = SY-DATUM.
INDX-USERA = SY-UNAME.
Export der Daten.
EXPORT F1 FROM F1
F2 FROM F2
ITAB3 FROM ITAB3
TO DATABASE INDX(ST) FROM WA_INDX ID INDXKEY.
*********************************************************TYPES: BEGIN OF TAB3_TYPE,
CONT(4),
END OF TAB3_TYPE.
DATA: INDXKEY LIKE INDX-SRTFD,
F1(4), F2 TYPE P,
TAB3 TYPE STANDARD TABLE OF TAB3_TYPE WITH
NON-UNIQUE DEFAULT KEY,
WA_INDX TYPE INDX.
INDXKEY = 'INDXKEY'.
IMPORT F1 = F1
F2 = F2
TAB3 = TAB3 FROM DATABASE INDX(ST) ID INDXKEY
TO WA_INDX.
Regards,
Ravi -
All values in internal table are not displaing in the script print program
Hi,
I am calling the script program.In main window all values in the internal table are not displaying. I wrote
write-form statement in loop. But not all the values are getting displayed. Only thel ast values getting dispalyed.
*& Report ZSCRIPT_116719
REPORT ZSCRIPT_116719.
************Table decleration***************
TABLES: mara, mbew, makt.
loop at i_makt into wa_makt.
endloop.
loop at i_MARA into wa_mara.
endloop.
LOOP AT I_MBEW INTO WA_MBEW.
ENDLOOP.
lv_price = 0.
********************Total Price******************
LOOP AT i_mbew INTO wa_mbew.
lv_price = lv_price + wa_mbew-stprs.
ENDLOOP.
end-of-selection.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
APPLICATION = 'TX'
ARCHIVE_INDEX =
ARCHIVE_PARAMS =
DEVICE = 'PRINTER'
DIALOG = 'X'
FORM = 'ZSCRIPT_719'
LANGUAGE = SY-LANGU
OPTIONS =
MAIL_SENDER =
MAIL_RECIPIENT =
MAIL_APPL_OBJECT =
RAW_DATA_INTERFACE = '*'
SPONUMIV =
IMPORTING
LANGUAGE =
NEW_ARCHIVE_PARAMS =
RESULT =
EXCEPTIONS
CANCELED = 1
DEVICE = 2
FORM = 3
OPTIONS = 4
UNCLOSED = 5
MAIL_OPTIONS = 6
ARCHIVE_ERROR = 7
INVALID_FAX_NUMBER = 8
MORE_PARAMS_NEEDED_IN_BATCH = 9
SPOOL_ERROR = 10
CODEPAGE = 11
OTHERS = 12
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'START_FORM'
EXPORTING
ARCHIVE_INDEX =
FORM = 'ZSCRIPT_719'
LANGUAGE = SY-LANGU
STARTPAGE = ' '
PROGRAM = 'ZSCRIPT_116719'
MAIL_APPL_OBJECT =
IMPORTING
LANGUAGE =
EXCEPTIONS
FORM = 1
FORMAT = 2
UNENDED = 3
UNOPENED = 4
UNUSED = 5
SPOOL_ERROR = 6
CODEPAGE = 7
OTHERS = 8
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*LOOP AT I_MBEW INTO WA_MBEW.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'DATA'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
IMPORTING
PENDING_LINES =
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
SPOOL_ERROR = 8
CODEPAGE = 9
OTHERS = 10
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*ENDLOOP.
If I give only one value it is showing the output. When I am fetching the data for range of values it i sshowing start_form is not there.
Plz let me know how to get the aa internal table values to be displayedhi
I shortened your program a bit. So we can go to essentials of your question.
You said you put in it in a loop.
What i see in your prog is:
REPORT zscript_116719.
************table decleration***************
TABLES: mara, mbew, makt.
LOOP AT i_makt INTO wa_makt.
ENDLOOP.
LOOP AT i_mara INTO wa_mara.
ENDLOOP.
LOOP AT i_mbew INTO wa_mbew.
ENDLOOP.
lv_price = 0.
********************total price******************
LOOP AT i_mbew INTO wa_mbew.
lv_price = lv_price + wa_mbew-stprs.
ENDLOOP.
END-OF-SELECTION.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
form = 'ZSCRIPT_719'
language = sy-langu.
CALL FUNCTION 'START_FORM'
EXPORTING
form = 'ZSCRIPT_719'
language = sy-langu
program = 'ZSCRIPT_116719'.
*LOOP AT I_MBEW INTO WA_MBEW.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'DATA'
function = 'SET'
type = 'BODY'
window = 'MAIN'.
*endloop.
1. Your loop is not a loop with this '*' in front of it.
2. Are you printing &wa_mbew-???& variables in your sap-script
3. is itab I_MBEW properly filled
Let me know.
Gr. Frank -
More than one print program for one sap script
Hi Experts,
I have more than one print program which is attached to one sap script. There is standard text used in the script which has variable as date, i want that date to be converted into the previous date but only for one specific print program. For rest of the print program it should behave as it is.
I have tried it using ( s_date - 1 ) formula and it is working fine. But the variable s_date is used in other parts of the program which is affecting rest of the functionality when i am using above said formula. I can't use other variable in standard text as it is used by other programs.
Please guide me to resolve this, thanks in advance.Well, I'm not sure if I understand the scenario 100%, but I think what you have is a standard text (that you cannot change) referring to variable &S_DATE&. You want this to display the previous day's date when the form is used by one print program but not when it's called by another.
Also, you don't want to change S_DATE to S_DATE - 1 for the whole printout, because apart from the text display, S_DATE is used elsewhere and you want to keep the date as S_DATE, not the previous day.
I assume that you can change the coding of the form.
If all of the above is correct, then you could change the value for S_DATE in the form to the previous day just before it calls the standard text and change it back after the output of the text is done. So right befor the INCLUDE for the standard text, you could use an IF statement in the form logic, query the value of SY-REPID (or SY-CPROG). You'll have to test which one shows the print program name. Depending on that, you can do S_DATE = S_DATE - 1 and after the INCLUDE, do the same thing and change it back to S_DATE = S_DATE + 1.
But honestly, this is a pretty shady programming technique... I mean, hard coding references to the print program name in the form logic is certainly not a very clean method -
Ho to find script and the related print program for print preview of PO
Hi All,
We are getting some text output on the print preview of a purchase order.
How can we determine the driver script and the corresponding print program for this.
Can you please guide on this.
Thanks in advance.
Regards,
SanjeetU Can check Driver program and form related to that program table is TNAPPR
Goto NACE t.code
Selct Application ---> click on output types
then u wil get one window there select proper output type and
double click on processing routines u wil get form name and related driver program name also
Plz try this....
Edited by: Upender Verma on Feb 9, 2009 1:33 PM
Edited by: Upender Verma on Feb 9, 2009 1:37 PM -
How to change a SAP script output without changing Print Program
Hi,
I want to change output of standard PO report printing object. I have to change the ZSAPSCRIPT but I have to keep the print program intact. please give me ideas.Hi for that you have to do following.
1. Create a ZPROGRAM
2. Write a Perform in your SAP Script.
3. Write Form inside it your ZPROGRAM.
Hope this will help you.
<i><b>Reward points for helpful ans.</b></i> -
Customer Statement using SAP Script and Standard print program RFKORD10
Using sap script and standard print program RFKORD10 I need to create a customer statement where the main window will be as follows
Invoice # InvoiceDate CustomerPO Debit Amt Credit Amt Total
6 7 8 9 10 11
6 7 8 9 10 11
Totals 12 13 14
Where company code BKORM-KUKRS
Invoice BSID-BELNR
Invoice date BSID-BLDAT
Customer PO VBKD-BSTKD
For each document number selected there will be one to many records in VBRP. For each invoice item in VBRP:
u2022 Select BSTKD from VBKD where
o VBELN = VBRP-VGBEL and
o POSNR = VBRP-VGPOS
u2022 If no hits then select BSTKD from VBKD where
o VBELN = VBRP-VGBEL
If there is more than one PO per invoice then list them in the Customer PO field without repeating the other fields.PO shouldnu2019t come more than once per invoice.
Debit Amt if BSEG-SHKZG = S then WRBTR ELSE 0
Credit Amt if BSEG-SHKZG = H then WRBTR ELSE 0
Total Debit Amt u2013 Credit Amt
Totals Subtotals
It will be of great help if some one can help me with the script and the alterations required in standard print program RFKORD10
Points will b rewarded for sure.
Thanks.Hi Suganya,
The custom form is getting displayed properly. But the requirement is to have it as an editable PDF. So the functional team is working on configuring the settings of PDF forms with customers email address.
But for right now, i customized the standard form F140_ACC_STAT_01 and standard print program RFKORD10_PDF and did the configuration. It is getting displayed (I tested only with the transaction FBL5N - customer open line items..)
Please let me know any further details on this.
Poornima -
How to find print program from script
Hi,
How can i find the print program from the script .
i unable to find in TNAPR table.
thanks,
sriiHi Sridhar,
U can find in NACE transaction.
Please check this link
search print program and sap script
with po no how to find script and print program for that po.
Best regards,
raam -
How we modify print program in script
hi gurus.
how we modify print program in script, please tell elaborately.Hi ..
first of all ... u have to check which is the print program for the given layout...
how u can find out is ... in NACE transaction... for certain o/p type .. there will be configuration done against the layout .. i mean for the particular layout .. a print program wud be assigned.
another way to find out the print program is thru table TNAPR..
once u find out the print program.. make sure u have to make changes in the print program .. i mean once u decide "for the requirement u have to make changes to the print program.
Reward points if it is useful.
Thanks,
Manjunath MS -
Hi All,
Where I can find a Print Program and Script associated with a particular PO.
Please suggest.
GSHi,
Go to me22n or me23n. Give the PO no . Click on Messages > See whether any output type exists or not. If exists then go to tyransaction nace . In th application select EF -Purchase Order. Click output type> In the output type search your output type Select it and then click on Processing routines you will see the program name & form name.
You can check with the output type in TNAPR table also . By giving output type in KSCHIL field it will give u print program & Form name.
Thanks,
Abhijit -
Search print program and sap script
hii , how can i find trigring print program and sap script for a particular purchase order.
regards Aditya
Edited by: aditya shrivastaba on Apr 14, 2008 9:59 AMHey,
First go with Me22 or 23 with po that you had, and then check with output type for that in the transaction. After that go to TNAPR table and check the corresponding form and print program.
Or else, go with NAST table in that put PO num in 123456 and put in OBJKY field in nast table. It will give you the output type of it, so that u can find the print program and lay out in TNAPR
Many thanks,
Raghu. -
Passing data to SAP script from print program-VF03
Hi All,
I have a stand alone print program which ahs the invoice number in its selection screen which when entered displays the layout of invoice by using a sap script.
Now since I have to get this layout displayed from VF03, I have added the program, sap script name and a subroutine which contains the code which was initially there under the start-of-selection event in the stand alone program, in NACE. I have replaced the selection screen parameter for invoice number in my program with nast-objky which contains the invoice entered in vf03.
But when I am entering the invoice in vf03 and selecting print preview, the data is getting captured in the internal table defined in my program but the same is not getting reflected in the layout displayed. So I am always getting the blank values in the output though I did not modify the original sap script at all. Pls help.Keep a breakpoint in your print program and see if your program is being triggered indeed. Do not forget to start Update debugging, otherwise it will not stop in your print program.
Regards,
Ravi -
How to fetch Print program name of a SAP script?
Hi abapers,
Could you please tell me how to fetch the name of a script's print program with the help of the script's name?
I have tried with table TNAPR and T-code NACE,it didnt help.
Is there any function module that returns the print program's name.
Please reply.
Thanks,
Suchi.hi ,
GOTO SE71 Txn
Enter standard script name.
Click on Display.
"in menu bar
"form------>Check--->text ----->press enter
Now you can view the standard print program name
Thanks & Regards -
How to attach print program and sap script for F150 transaction
How to attach print program and Z sap script for F150 transaction
Hi,
you can find the customization for dunning in transaction SPRO under this path: Financial Accounting->Accounts Receivable and Accaounts Payable->Business Transactions->Dunning.
Kostas
Maybe you are looking for
-
Only display 1 page. WHY?
I have a report that only display 1 page of data. However I run the same query in TOAD and receive a large amount of data. WHY. See query below. In Reports, I commented out the order by clause. Thanks. select distinct B.NAME, err.bureau_code,
-
I bought an iPad 2 for my mom, she couldn't use it because the windows keep running away from her. that's why i have to return it
-
Query to get the List of Reports on a Universe
Hi All, I want to write a query to get all the Web I and Crystal Reports that access a particular universe. Can anyone suggest me where to start. This is in BO 3.1 against Oracle databse.
-
For Assistance: IDocs in Status 02
Dear SAP Peeps, We have some issues on an existing HR interface. Approximately 2 to 3 idocs per two weeks use to end after their generation in PGH. They end up in status 02-Error passing data to port. Error description is "codepage of receiver system
-
Hi keep getting a faild dil. from postmaster from e-mails I did not send so now Iam blocked from sending e-mails and can,t contact sup. by email. some time a hundred a day