* Der Report besteht aus folgenden Teilen:
* A. Allgemein: Nachricht
* Es wird der Ablauf als Nachrichten-Report realisiert. Wie
* ьblich wird eine Einstiegsroutine (ENTRY) definiert, die
* in die Verarbeitungsroutine (PROCESSING) verzweigt. Von
* dort werden die verschiedene Verarbeitungschritte aufgerufen.
* Dieser allgemeine Teil dient im wesentlichen zur Status-
* fortschreibung.
* B. Speziell: Packliste
* Der spezifische Teil realisiert die Datenbeschaffung, sowie
* die eigentliche Ausgabe. Dazu werden die entsprechenden Text-
* elemente des zugehцrigen Formulars (s.o.) ausgegeben. AuЯerdem
* ist zu Beginn der grundlegende Aufbau und die Realsierung der
* der Verpackung von Lieferungen beschrieben.
DATA: z_country2 LIKE t005t-landx.
* - Add define
TYPES:
ty_itcsy TYPE STANDARD TABLE OF itcsy.
* start of change for
DATA: BEGIN OF t_deliveryflow OCCURS 0, "VBFA delivery flow
vbeln LIKE vbfa-vbeln, "Subsequent sales and distribu
END OF t_deliveryflow.
TYPES : t_intab TYPE TABLE OF itcsy,
t_outtab TYPE TABLE OF itcsy.
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.
TYPES: BEGIN OF t_vbplk.
INCLUDE TYPE vbplk.
TYPES: END OF t_vbplk.
DATA : it_vbplk TYPE TABLE OF t_vbplk,
wa_vbplk LIKE LINE OF it_vbplk.
DATA : it_vbplk1 TYPE TABLE OF t_vbplk,
wa_vbplk1 LIKE LINE OF it_vbplk1.
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
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.
DATA: v_gtot TYPE vekp-brgew. "total weight of the delivery
TYPES: BEGIN OF t_gtot,
venum TYPE vekp-venum,
brgew TYPE vekp-brgew,
END OF t_gtot.
DATA: it_gtot TYPE TABLE OF t_gtot,
wa_gtot TYPE t_gtot.
TYPES: BEGIN OF t_carton,
venum TYPE vekp-venum,
END OF t_carton.
DATA: it_carton TYPE TABLE OF t_carton,
wa_carton TYPE t_carton.
TYPES : BEGIN OF t_item ,
posnr1 TYPE vbplp-posnr,
material1 TYPE mara-matnr,
brgew1 TYPE vbplp-brgew,
grunit TYPE likp-gewei,
vemng1 TYPE vbplp-brgew,
vemeh1 TYPE vbplp-vemeh,
item_weight1 TYPE n,
arktx1 TYPE vbplp-arktx,
vboxcnt TYPE i,
END OF t_item.
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: v_groswt TYPE vbplk-brgew.
DATA: v_grosswt TYPE f.
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
*----------------------------------------------------------------------*
* 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.
*---------------------------------------------------------------------*
* 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.
*----------------------------------------------------------------------*
* 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 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.
IF NOT t_cartons[] IS INITIAL.
it_carton[] = t_cartons[].
LOOP AT it_carton INTO wa_carton.
SELECT SINGLE brgew
INTO wa_gtot-brgew
FROM vekp
WHERE venum = wa_carton-venum.
COLLECT wa_gtot INTO it_gtot.
CLEAR wa_gtot.
ENDLOOP.
LOOP AT it_gtot INTO wa_gtot.
PERFORM set_textsymbol USING '&TOTWEIGHT&'
wa_gtot-brgew.
ENDLOOP.
ELSE.
it_vbplk[] = xvbplk[].
LOOP AT it_vbplk INTO wa_vbplk.
SELECT SINGLE brgew
INTO wa_vbplk1-brgew
FROM vekp
WHERE venum = wa_vbplk-venum.
COLLECT wa_vbplk1 INTO it_vbplk1.
CLEAR wa_vbplk1.
ENDLOOP.
LOOP AT it_vbplk1 INTO wa_vbplk1.
PERFORM set_textsymbol USING '&TOTWEIGHT&'
wa_vbplk1-brgew.
ENDLOOP.
ENDIF.
LOOP AT it_item INTO wa_item.
IF wa_item-grunit = 'G'.
MOVE wa_item-brgew1 TO v_grosswt.
v_grosswt = v_grosswt / 1000.
MOVE v_grosswt TO wa_item-brgew1.
wa_item-grunit = 'KG'.
ENDIF.
PERFORM set_textsymbol USING '&POSNR1&'
wa_item-posnr1.
PERFORM set_textsymbol USING '&material1&'
wa_item-material1.
PERFORM set_textsymbol USING '&BRGEW1&'
wa_item-brgew1.
PERFORM set_textsymbol USING '&VBOXCNT&'
wa_item-vboxcnt.
PERFORM set_textsymbol USING '&vemng1&'
wa_item-vemng1.
PERFORM set_textsymbol USING '&vemeh1&'
wa_item-vemeh1.
PERFORM set_textsymbol USING '&arktx1&'
wa_item-arktx1.
PERFORM set_textsymbol USING '&grunit&'
wa_item-grunit.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEMPOS'.
* 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.
MOVE vbplk-brgew TO v_groswt.
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.
*Perform to get the all the details to the internal table it_item.
PERFORM item_list.
* 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.
* perform to get the item wise details.
PERFORM total_weight.
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.
*
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.
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.
* 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.
* 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.
SELECT SINGLE *
FROM adrc
WHERE addrnumber = v_adrnr.
*& 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.
* IF v_kdmat <> ' '.
* PERFORM set_textsymbol USING '&MATERIAL&'
* v_kdmat.
* ELSE.
* PERFORM set_textsymbol USING '&MATERIAL&'
* vbplp-matnr.
* ENDIF.
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.
*
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.
CLEAR v_btgew.
DESCRIBE TABLE t_venum LINES v_lin. "
CHECK v_lin GT 0. "
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.
**Form to get the Gross Weight in KG if the weight is in "G".
PERFORM set_textsymbol USING '&GROSS_WEIGHT1&'
v_grwt.
PERFORM set_textsymbol USING '&GROSS_WEIGHT_UNIT1&'
v_gunit.
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
* 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
**form to get the Net weight of the Delivery.
*&---------------------------------------------------------------------*
*& 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
*** form to copy all the details from the vbplp structure
* in to an internal table it_tem.
*&---------------------------------------------------------------------*
*& Form item_list
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM item_list.
CLEAR : wa_item1, wa_item.
MOVE vbplp-posnr TO wa_item-posnr1.
MOVE vbplp-gewei TO wa_item-grunit.
MOVE vbplp-brgew TO wa_item-brgew1.
MOVE vbplp-vemng TO wa_item-vemng1.
MOVE vbplp-vemeh TO wa_item-vemeh1.
MOVE vbplp-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.
ENDFORM. " item_list
***form to get the item wise details of the Delivery
*&---------------------------------------------------------------------*
*& 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.
wa_item1-vemng1 = wa_item1-vemng1 + wa_item-vemng1.
MODIFY it_item FROM wa_item1 TRANSPORTING brgew1 vboxcnt vemng1
WHERE material1 = wa_item1-material1
AND posnr1 = wa_item1-posnr1.
ENDIF.
ENDLOOP.
ENDFORM. " TOTAL_WEIGHT
***form to get the ship to address of the Delivery
*---------------------------------------------------------------------*
* FORM GET_NAME *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> IN_TAB4 *
* --> OUT_TAB4 *
*---------------------------------------------------------------------*
FORM get_name TABLES intab TYPE t_intab
out_tab TYPE t_outtab.
DATA : wa_intab LIKE itcsy,
w_outtab LIKE itcsy.
DATA v_adrnr_we TYPE adrc-addrnumber.
READ TABLE intab INTO wa_intab INDEX 1.
v_adrnr_we = wa_intab-value.
SELECT SINGLE * FROM adrc WHERE addrnumber = v_adrnr_we.
SELECT SINGLE landx
INTO z_country2
FROM t005t
WHERE land1 = adrc-country
and SPRAS = 'EN'.
READ TABLE out_tab INTO w_outtab WITH KEY name = 'Z_NAME1'.
IF sy-subrc EQ 0.
w_outtab-value = adrc-name1.
MODIFY out_tab FROM w_outtab INDEX sy-tabix.
ENDIF.
READ TABLE out_tab INTO w_outtab WITH KEY name = 'Z_NAME2'.
IF sy-subrc EQ 0.
w_outtab-value = adrc-name2.
MODIFY out_tab FROM w_outtab INDEX sy-tabix.
ENDIF.
READ TABLE out_tab INTO w_outtab WITH KEY name = 'Z_NAME3'.
IF sy-subrc EQ 0.
w_outtab-value = adrc-name3.
MODIFY out_tab FROM w_outtab INDEX sy-tabix.
ENDIF.
READ TABLE out_tab INTO w_outtab WITH KEY name = 'Z_NAME4'.
IF sy-subrc EQ 0.
w_outtab-value = adrc-name4.
MODIFY out_tab FROM w_outtab INDEX sy-tabix.
ENDIF.
READ TABLE out_tab INTO w_outtab WITH KEY name = 'Z_STREET'.
IF sy-subrc EQ 0.
w_outtab-value = adrc-street.
MODIFY out_tab FROM w_outtab INDEX sy-tabix.
ENDIF.
READ TABLE out_tab INTO w_outtab WITH KEY name = 'Z_CITY1'.
IF sy-subrc EQ 0.
w_outtab-value = adrc-city1.
MODIFY out_tab FROM w_outtab INDEX sy-tabix.
ENDIF.
READ TABLE out_tab INTO w_outtab WITH KEY name = 'Z_CITY2'.
IF sy-subrc EQ 0.
w_outtab-value = adrc-city2.
MODIFY out_tab FROM w_outtab INDEX sy-tabix.
ENDIF.
READ TABLE out_tab INTO w_outtab WITH KEY name = 'Z_COUNTRY2'.
IF sy-subrc EQ 0.
w_outtab-value = adrc-country.
MODIFY out_tab FROM w_outtab INDEX sy-tabix.
ENDIF.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.