Search on this Website

Thursday, April 26, 2007

Code for Inbound IDOC, USER exit code examples ORDERS05

*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(DCONTROL_RECORD_OUT) LIKE EDIDC STRUCTURE EDIDC
*" OPTIONAL
*" VALUE(DORDER_NUMBER) LIKE VBAK-VBELN OPTIONAL
*" VALUE(DXVBAK) LIKE VBAK STRUCTURE VBAK OPTIONAL
*" VALUE(DXHVBKD) LIKE VBKD STRUCTURE VBKD OPTIONAL
*" TABLES
*" DXVBKD STRUCTURE VBKD OPTIONAL
*" DXVBPA STRUCTURE VBPA OPTIONAL
*" DXVBAP STRUCTURE VBAP OPTIONAL
*" DXVBEP STRUCTURE VBEP OPTIONAL
*" DIKOMV STRUCTURE KOMV OPTIONAL
*" DIKOMVD STRUCTURE KOMVD OPTIONAL
*" DINT_EDIDD STRUCTURE EDIDD OPTIONAL
*" EXCEPTIONS
*" ERROR_MESSAGE_RECEIVED
*" DATA_NOT_RELEVANT_FOR_SENDING
*"----------------------------------------------------------------------
*&---------------------------------------------------------------------*
*& Include ZXVEDU15
*&---------------------------------------------------------------------*
*DESCRIPTION: MODIFY STATUS SETTINGS IN IDOC, CHANGE LENGTH OF CONSTANT
* C_0, add l_unitpr and modify calculation of unitpr, change
* code on pos_jurisdiction_code, add c_origin_mc for mixed
* case entry in SAP instead of Upper Case. Change freight
* terms from field KDKG1 to SDABW. Add line item delivery
* block (VBEP-LIFSP).


*************************************************************************
*DESCRIPTION: CHANGE SALES ORDER LINE ITEM UOM FOR CONVERSION TO GAL
* USING FMOD 'MD_CONVERT_MATERIAL_UNIT'. INPUT UOM WILL BE VBAP-VRKME
* THE SALES UNIT OF MEASURE.
*************************************************************************
*DESCRIPTION: ADD TO ZEDI TEXT DXVBEP-WADAT - GOODS ISSUE DATE; ZEDH
* TEXT ADD VBAK-IHREZ - YOUR REFERENCE FIELD FOR POPS INBOUND MISSING
* ORDERS.
*************************************************************************
*DESCRIPTION: Outbound Purchase Order line item text is not always being
* generated. for documentation. Correction was to remove EXIT command
* after reading table for condition ZPRV.
*************************************************************************
DATA:BEGIN OF t_komv OCCURS 0,
knumh LIKE konv-knumh,
END OF t_komv.
DATA:BEGIN OF t_days OCCURS 0,
days TYPE i,
days1 TYPE i,
datab LIKE konh-datab,
datbi LIKE konh-datbi,
END OF t_days.
*Data declaration
DATA : l_tabix LIKE sy-tabix,
l_cmgst LIKE vbuk-cmgst , "Overall status of credit checks
l_gbstk LIKE vbuk-gbstk , "Overall processing status of document
l_bismt LIKE mara-bismt, "Old material number
l_outmeng LIKE ekpo-menge,
l_c_meng(13),

l_unitpr TYPE p DECIMALS 4, "vbap-netwr,
* l_up,
l_up(23),

l_menge LIKE ekpo-menge,
l_found TYPE c,
l_meins TYPE mara-meins,
l_kdkg1 LIKE vbkd-kdkg1,
l_gbsta LIKE vbup-gbsta,
l_lfsta LIKE vbup-lfsta,
l_kondm LIKE vbap-kondm,
l_oidrc LIKE vbap-oidrc,
l_tragr LIKE mara-tragr,
l_abstk LIKE vbuk-abstk,
l_lfstk LIKE vbuk-lfstk,
l_spstg LIKE vbuk-spstg,
l_provi(1) TYPE c,

l_knumv TYPE vbak-knumv,
l_erdat TYPE vbak-erdat,
l_erzet TYPE vbak-erzet,
l_days TYPE i,
l_days1 TYPE i,
l_datab LIKE konh-datab,
l_datbi LIKE konh-datbi.

DATA : v_kunnr TYPE vbpa-kunnr,
v_txjcd1 TYPE t001w-txjcd,
v_txjcd2 TYPE t001w-txjcd,
v_scacd TYPE lfa1-scacd,
v_tdlnr TYPE tvro-tdlnr.
DATA : x_e1edkt1 LIKE e1edkt1, " Segments structure
x_e1edkt2 LIKE e1edkt2,
x_e1edpt1 LIKE e1edpt1,
x_e1edpt2 LIKE e1edpt2,
x_edidd LIKE edidd,
x_e1edp01 LIKE e1edp01,
x_e1edk01 LIKE e1edk01.
DATA : t_clbatch LIKE clbatch OCCURS 0 WITH HEADER LINE.
* CONSTANTS
CONSTANTS : c_gal TYPE mara-meins VALUE 'GLL', " Give constant value GAL
Required unit
c_zedh(5) TYPE c VALUE 'ZEDH',
c_zedi(5) TYPE c VALUE 'ZEDI',
* Fields for ZEDH
c_faksk(5) TYPE c VALUE 'FAKSK',
c_oidrc(16) TYPE c VALUE 'DRC_CODE IS_OIL',
c_erdat(5) TYPE c VALUE 'ERDAT',
c_erzet(5) TYPE c VALUE 'ERZET',
c_aedat(5) TYPE c VALUE 'AEDAT',
c_cmgst(5) TYPE c VALUE 'CMGST',
c_gbstk(5) TYPE c VALUE 'GBSTK',
c_traty(5) TYPE c VALUE 'TRATY',
c_ihrez(5) TYPE c VALUE 'IHREZ',
* Fields for ZEDI
c_mprok(5) TYPE c VALUE 'MPROK',
c_spart(5) TYPE c VALUE 'SPART',
c_topc(5) TYPE c VALUE 'TOPC',
c_unitpr(6) TYPE c VALUE 'UnitPR',
c_smat(5) TYPE c VALUE 'SMAT',
c_konda(5) TYPE c VALUE 'KONDA',
c_vehicle TYPE atnam VALUE 'VEHICLE_ID',
c_frt_terms(5) TYPE c VALUE 'KDKG1',
c_ov_stat(5) TYPE c VALUE 'GBSTA',
c_del_stat(5) TYPE c VALUE 'LFSTA',
c_wadat(5) TYPE c VALUE 'WADAT',
c_mat_pric(5) TYPE c VALUE 'KONDM',
c_pric_zon(5) TYPE c VALUE 'OIDRC',
c_trans_group(5) TYPE c VALUE 'TRAGR',
c_abstk(5) TYPE c VALUE 'ABSTK',
c_lfstk(5) TYPE c VALUE 'LFSTK',
c_spstg(5) TYPE c VALUE 'SPSTG',
c_provi(5) TYPE c VALUE 'PROVI',
c_valid_to(8) TYPE c VALUE 'VALID_TO',
c_valid_from(10) TYPE c VALUE 'VALID_FROM',
c_datetime(8) TYPE c VALUE 'DATETIME',
* Start Of change by amit khari on 23-06-06
c_dest(11) TYPE c VALUE 'DESTINATION',
c_origin(6) TYPE c VALUE 'ORIGIN',
c_pos_jur(21) TYPE c VALUE 'POS_JURISDICTION_CODE',
c_we(2) TYPE c VALUE 'WE',
*BEGIN OF CHANGE RDVK901578
* c_0(5) TYPE c VALUE '00000',
c_0(6) TYPE c VALUE '000000',
c_origin_mc(6) TYPE c VALUE 'Origin',
c_lifsp(5) TYPE c VALUE 'LIFSP',
*END OF CHANGE RDVK901578
c_ernam(5) TYPE c VALUE 'ERNAM',
c_tdlnr(5) TYPE c VALUE 'TDLNR'.
* *----------------------------------------------------------------------------------------
*Processing segments
*----------------------------------------------------------------------------------------
LOOP AT dint_edidd FROM l_tabix.
IF dint_edidd-segnam = 'E1EDKT1'.
l_tabix = sy-tabix .
EXIT.
ELSEIF
dint_edidd-segnam = 'E1EDP01' OR
dint_edidd-segnam = 'E1EDL37' OR
dint_edidd-segnam = 'E1EDS01'.
l_tabix = sy-tabix .
EXIT.
ENDIF. "dint_edidd-segnam =
'E1EDKT1'
ENDLOOP. "dint_edidd FROM l_tabix
IF l_found <> 'X'.
* Populate fields to modify the existing segment field value.
SELECT SINGLE cmgst
gbstk
abstk
lfstk
spstg
INTO (l_cmgst , l_gbstk ,
l_abstk , l_lfstk , l_spstg)
FROM vbuk
WHERE vbeln = dxvbak-vbeln.
x_edidd-segnam = 'E1EDKT1'.
x_e1edkt1-tdid = c_zedh.
x_e1edkt1-tsspras = 'E'.
x_e1edkt1-tsspras_iso = 'EN'.
x_edidd-sdata = x_e1edkt1.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
l_tabix = l_tabix + 1.
x_edidd-segnam = 'E1EDKT2'.
*BEGIN OF CHANGE RDVK901578
* For creator of document
CONCATENATE c_ernam
dxvbak-ernam
INTO x_e1edkt2-tdline
SEPARATED BY space.
x_e1edkt2-tdformat = '*'.
x_edidd-sdata = x_e1edkt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
*END OF CHANGE RDVK901578
*BEGIN OF CHANGE RDVK902758
* ADD VBAK 'YOUR REFERENCE' FIELD
CONCATENATE c_ihrez
dxvbak-ihrez
INTO x_e1edkt2-tdline
SEPARATED BY space.
x_e1edkt2-tdformat = '*'.
x_edidd-sdata = x_e1edkt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
*END OF CHANGE RDVK902758
* Concatenate field and field value in exiting segment field
CONCATENATE c_faksk
dxvbak-faksk
INTO x_e1edkt2-tdline
SEPARATED BY space.
x_e1edkt2-tdformat = '*'.
x_edidd-sdata = x_e1edkt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
CONCATENATE c_oidrc
dxvbak-oidrc
INTO x_e1edkt2-tdline
SEPARATED BY space.
x_e1edkt2-tdformat = '*'.
x_edidd-sdata = x_e1edkt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
CONCATENATE c_erdat
dxvbak-erdat
INTO x_e1edkt2-tdline
SEPARATED BY space.
x_e1edkt2-tdformat = '*'.
x_edidd-sdata = x_e1edkt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
CONCATENATE c_erzet
dxvbak-erzet
INTO x_e1edkt2-tdline
SEPARATED BY space.
x_e1edkt2-tdformat = '*'.
x_edidd-sdata = x_e1edkt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
CONCATENATE c_aedat
dxvbak-aedat
INTO x_e1edkt2-tdline
SEPARATED BY space.
x_e1edkt2-tdformat = '*'.
x_edidd-sdata = x_e1edkt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
CONCATENATE c_cmgst
l_cmgst
INTO x_e1edkt2-tdline
SEPARATED BY space.
x_e1edkt2-tdformat = '*'.
x_edidd-sdata = x_e1edkt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
CONCATENATE c_gbstk
l_gbstk
INTO x_e1edkt2-tdline
SEPARATED BY space.
x_e1edkt2-tdformat = '*'.
x_edidd-sdata = x_e1edkt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
CONCATENATE c_traty
dxvbkd-traty
INTO x_e1edkt2-tdline
SEPARATED BY space.
x_e1edkt2-tdformat = '*'.
x_edidd-sdata = x_e1edkt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
CONCATENATE c_abstk
l_abstk
INTO x_e1edkt2-tdline
SEPARATED BY space.
x_e1edkt2-tdformat = '*'.
x_edidd-sdata = x_e1edkt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
CONCATENATE c_lfstk
l_lfstk
INTO x_e1edkt2-tdline
SEPARATED BY space.
x_e1edkt2-tdformat = '*'.
x_edidd-sdata = x_e1edkt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
CONCATENATE c_spstg
l_spstg
INTO x_e1edkt2-tdline
SEPARATED BY space.
x_e1edkt2-tdformat = '*'.
x_edidd-sdata = x_e1edkt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
*ABIR + 08082006
l_knumv = dxvbak-knumv.
l_erdat = dxvbak-erdat.
l_erzet = dxvbak-erzet.
LOOP AT dikomv WHERE knumv = l_knumv.
IF NOT dikomv-knumh IS INITIAL.
t_komv-knumh = dikomv-knumh.
APPEND t_komv.
ELSE.
ENDIF.
ENDLOOP.
IF sy-subrc = 0.
LOOP AT t_komv.
CLEAR l_datab.
CLEAR l_datbi.
SELECT SINGLE datab
datbi
INTO (l_datab , l_datbi)
FROM konh
WHERE knumh = t_komv-knumh.
IF l_datab < i_datum_bis =" sy-datum" i_datum_von =" l_datab" i_kz_excl_von =" '0'" i_kz_incl_bis =" '0'" i_kz_ult_bis =" '" i_kz_ult_von =" '" i_stgmeth =" '0'" i_szbmeth =" '1'" e_tage =" l_days" days_method_not_defined =" 1" others =" 2"> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF NOT l_days IS INITIAL.
t_days-days = l_days.
t_days-datab = l_datab.
APPEND t_days.
ENDIF.
ELSEIF l_datab > sy-datum.
l_days = l_datab - sy-datum.
IF NOT l_days IS INITIAL.
t_days-days = l_days.
t_days-datab = l_datab.
APPEND t_days.
ENDIF.
ENDIF.
IF l_datbi < i_datum_bis =" sy-datum" i_datum_von =" l_datbi" e_tage =" l_days1" days_method_not_defined =" 1" others =" 2"> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF NOT l_days1 IS INITIAL.
t_days-days1 = l_days1.
t_days-datbi = l_datbi.
MODIFY t_days INDEX sy-tabix TRANSPORTING days1 datbi.
ENDIF.
ELSEIF l_datbi > sy-datum.
l_days1 = l_datbi - sy-datum.
IF NOT l_days1 IS INITIAL.
t_days-days1 = l_days1.
t_days-datbi = l_datbi.
MODIFY t_days INDEX sy-tabix TRANSPORTING days1 datbi.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
SORT t_days BY days days1.
READ TABLE t_days INDEX 1.
CONCATENATE c_valid_to
t_days-datab
INTO x_e1edkt2-tdline
SEPARATED BY space.
x_e1edkt2-tdformat = '*'.
x_edidd-sdata = x_e1edkt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
CONCATENATE c_valid_from
t_days-datbi
INTO x_e1edkt2-tdline
SEPARATED BY space.
x_e1edkt2-tdformat = '*'.
x_edidd-sdata = x_e1edkt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
CONCATENATE c_datetime
l_erdat
l_erzet
INTO x_e1edkt2-tdline
SEPARATED BY space.
x_e1edkt2-tdformat = '*'.
x_edidd-sdata = x_e1edkt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
ENDIF. "l_found <> 'X'.
CLEAR : x_edidd ,
x_e1edkt2.
DO.
CLEAR: x_e1edp01 ,
l_found .
LOOP AT dint_edidd FROM l_tabix.
IF dint_edidd-segnam = 'E1EDP01'.
x_e1edp01 = dint_edidd-sdata.
l_tabix = sy-tabix + 1.
l_found = 'X'.
EXIT.
ENDIF. " dint_edidd-segnam =
'E1EDP01'
ENDLOOP. "at dint_edidd
IF l_found <> 'X'.
EXIT.
ENDIF. "l_found <> 'X'
LOOP AT dint_edidd FROM l_tabix .
CLEAR: l_found .
IF dint_edidd-segnam = 'E1EDPT1'.
l_tabix = sy-tabix .
l_found = 'X'.
EXIT.
ELSEIF dint_edidd-segnam = 'E1EDC01' OR
dint_edidd-segnam = 'E1EDP01' OR
dint_edidd-segnam = 'E1CUCFG' OR
dint_edidd-segnam = 'E1EDL37' OR
dint_edidd-segnam = 'E1EDS01'.
l_tabix = sy-tabix .
EXIT.
ENDIF. "dint_edidd-segnam =
'E1EDPT1'
ENDLOOP. "AT dint_edidd
x_edidd-segnam = 'E1EDPT1'.
x_e1edpt1-tdid = c_zedi.
x_e1edpt1-tsspras = 'E'.
x_e1edpt1-tsspras_iso = 'EN'.
x_edidd-sdata = x_e1edpt1.
l_tabix = l_tabix.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
x_edidd-segnam = 'E1EDPT2'.
l_tabix = l_tabix + 1.
READ TABLE dxvbap WITH KEY posnr = x_e1edp01-posex .
IF sy-subrc = 0.
l_kondm = dxvbap-kondm.
l_oidrc = dxvbap-oidrc.
ENDIF.
CONCATENATE c_mprok
dxvbap-mprok
INTO x_e1edpt2-tdline
SEPARATED BY space.
x_e1edpt2-tdformat = '*'.
x_edidd-sdata = x_e1edpt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
*BEGIN OF INSERT RDVK901577
*ADD SALES ORDER LINE ITEM DELIVERY BLOCK
READ TABLE dxvbep WITH KEY vbeln = dxvbap-vbeln
posnr = x_e1edp01-posex.
CONCATENATE c_lifsp
dxvbep-lifsp
INTO x_e1edpt2-tdline
SEPARATED BY space.
x_e1edpt2-tdformat = '*'.
x_edidd-sdata = x_e1edpt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
*END OF INSERT RDVK901577
*BEGIN OF CHANGE RDVK902758
* Sales Order Schedule Goods Issue Date
CONCATENATE c_wadat
dxvbep-wadat
INTO x_e1edpt2-tdline
SEPARATED BY space.
x_e1edpt2-tdformat = '*'.
x_edidd-sdata = x_e1edpt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix.
*END OF CHANGE RDVK902758
CONCATENATE c_spart
dxvbap-spart
INTO x_e1edpt2-tdline
SEPARATED BY space.
x_e1edpt2-tdformat = '*'.
x_edidd-sdata = x_e1edpt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
MOVE dxvbap-kwmeng TO l_menge .
** Conversion routine to get store value
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
EXPORTING
input = dxvbap-meins
language = sy-langu
IMPORTING
output = l_meins
EXCEPTIONS
unit_not_found = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
**
* Function for converting the unit and import quantity value after change
CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
EXPORTING
i_matnr = dxvbap-matnr

* i_in_me = l_meins
i_in_me = dxvbap-vrkme

i_out_me = c_gal
i_menge = l_menge
IMPORTING
e_menge = l_outmeng
EXCEPTIONS
error_in_application = 1.
IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
WRITE l_outmeng TO l_c_meng NO-GROUPING.
CONCATENATE c_topc
l_c_meng
INTO x_e1edpt2-tdline
SEPARATED BY space.
x_e1edpt2-tdformat = '*'.
x_edidd-sdata = x_e1edpt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
* calculate unit price
* Added IF condition to prevent shortdump for Contracts
IF dxvbap-netwr > 0 AND dxvbap-kwmeng > 0.

* l_up = dxvbap-netwr / dxvbap-kwmeng.
CLEAR : l_unitpr,
l_up.
l_unitpr = ( dxvbap-netwr / dxvbap-kwmeng ) / 100.
WRITE l_unitpr TO l_up NO-GROUPING DECIMALS 4. "Z29AXM ATUL
* write l_unitpr to l_up.
SHIFT l_up LEFT DELETING LEADING space.

ENDIF.
CONCATENATE c_unitpr
l_up
INTO x_e1edpt2-tdline
SEPARATED BY space.
x_e1edpt2-tdformat = '*'.
x_edidd-sdata = x_e1edpt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
* Populate old material number
SELECT SINGLE bismt tragr
INTO (l_bismt , l_tragr)
FROM mara
WHERE matnr = dxvbap-matnr.
CONCATENATE c_smat
l_bismt
INTO x_e1edpt2-tdline
SEPARATED BY space.
x_e1edpt2-tdformat = '*'.
x_edidd-sdata = x_e1edpt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
*ENDLOOP.

* READ TABLE dxvbkd WITH KEY posnr = x_e1edp01-posex .
READ TABLE dxvbkd WITH KEY
vbeln = dxvbkd-vbeln
posnr = x_e1edp01-posex .

* l_kdkg1 = dxvbkd-kdkg1. "Freight Terms Code only
l_kdkg1 = dxvbkd-sdabw.

LOOP AT dxvbkd.
CONCATENATE c_konda "Price group code only
dxvbkd-konda
INTO x_e1edpt2-tdline
SEPARATED BY space.
x_e1edpt2-tdformat = '*'.
x_edidd-sdata = x_e1edpt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
* Add Vehicle ID only is BATCH number is present
IF NOT dxvbap-charg IS INITIAL. " For Batch number only
CALL FUNCTION '/SAPMP/CE1_BATCH_GET_DETAIL'
EXPORTING
matnr = dxvbap-matnr
charg = dxvbap-charg
werks = dxvbap-werks
get_classification = 'X'
TABLES
* T_API_CH_ATT =
char_of_batch = t_clbatch
* EXCEPTIONS
* NO_MATERIAL = 1
* NO_BATCH = 2
* NO_PLANT = 3
* MATERIAL_NOT_FOUND = 4
* PLANT_NOT_FOUND = 5
* NO_AUTHORITY = 6
* BATCH_NOT_EXIST = 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.
READ TABLE t_clbatch WITH KEY atnam = 'VEHICLE_ID' .
WRITE t_clbatch-atwtb+4(8) TO
t_clbatch-atwtb+4(8) RIGHT-JUSTIFIED. "AS VEHICLE Field is 12
char.
IF sy-subrc = 0.
CONCATENATE c_vehicle "Vehicle ID
t_clbatch-atwtb
INTO x_e1edpt2-tdline
SEPARATED BY space.
x_e1edpt2-tdformat = '*'.
x_edidd-sdata = x_e1edpt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
ENDIF.
ENDIF. "not DXVBAP-CHARG is intia


CLEAR : v_kunnr,
v_txjcd1,
v_txjcd2.
IF dxvbkd-inco2 = c_dest.

* READ TABLE dxvbpa WITH KEY posnr = x_e1edp01-posex
READ TABLE dxvbpa WITH KEY vbeln = dxvbkd-vbeln
posnr = x_e1edp01-posex

parvw = c_we.
IF sy-subrc NE 0.

* READ TABLE dxvbpa WITH KEY posnr = c_0
READ TABLE dxvbpa WITH KEY vbeln = dxvbkd-vbeln
posnr = c_0

parvw = c_we.
ENDIF.
SELECT SINGLE txjcd
INTO v_txjcd1
FROM kna1
WHERE kunnr EQ dxvbpa-kunnr.
CONCATENATE c_pos_jur
v_txjcd1
INTO x_e1edpt2-tdline
SEPARATED BY space.
x_e1edpt2-tdformat = '*'.
x_edidd-sdata = x_e1edpt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
ELSEIF dxvbkd-inco2 = c_origin
OR dxvbkd-inco2 = c_origin_mc.
SELECT SINGLE txjcd
INTO v_txjcd2
FROM t001w
*
* WHERE werks = dxvbap-vbeln.
WHERE werks = dxvbap-werks.

CONCATENATE c_pos_jur
v_txjcd2
INTO x_e1edpt2-tdline
SEPARATED BY space.
x_e1edpt2-tdformat = '*'.
x_edidd-sdata = x_e1edpt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
ENDIF.
*For freight terms code only
CONCATENATE c_frt_terms
l_kdkg1
INTO x_e1edpt2-tdline
SEPARATED BY space.
x_e1edpt2-tdformat = '*'.
x_edidd-sdata = x_e1edpt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
SELECT SINGLE gbsta
lfsta
INTO (l_gbsta , l_lfsta)
FROM vbup
*
* where posnr = x_e1edp01-posex.
WHERE vbeln = dxvbap-vbeln
AND posnr = dxvbap-posnr.

IF sy-subrc = 0.
*For Overall Status code only
CONCATENATE c_ov_stat
l_gbsta
INTO x_e1edpt2-tdline
SEPARATED BY space.
x_e1edpt2-tdformat = '*'.
x_edidd-sdata = x_e1edpt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
*For delivery status code only
CONCATENATE c_del_stat
l_lfsta
INTO x_e1edpt2-tdline
SEPARATED BY space.
x_e1edpt2-tdformat = '*'.
x_edidd-sdata = x_e1edpt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
ENDIF.
*For Material Pricing Group code only
CONCATENATE c_mat_pric
l_kondm
INTO x_e1edpt2-tdline
SEPARATED BY space.
x_e1edpt2-tdformat = '*'.
x_edidd-sdata = x_e1edpt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
*For Pricing Zone code only
CONCATENATE c_pric_zon
l_oidrc
INTO x_e1edpt2-tdline
SEPARATED BY space.
x_e1edpt2-tdformat = '*'.
x_edidd-sdata = x_e1edpt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
*For Transportation Group code only
CONCATENATE c_trans_group
l_tragr
INTO x_e1edpt2-tdline
SEPARATED BY space.
x_e1edpt2-tdformat = '*'.
x_edidd-sdata = x_e1edpt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
*For Provisional Indicator code only
READ TABLE dikomv WITH KEY knumv = dxvbak-knumv
kposn = dxvbap-posnr
kschl = 'ZPRV'.
IF sy-subrc = 0.
l_provi = 'Y'.
* EXIT.
ELSE.
l_provi = 'N'.
ENDIF.
CONCATENATE c_provi
l_provi
INTO x_e1edpt2-tdline
SEPARATED BY space.
x_e1edpt2-tdformat = '*'.
x_edidd-sdata = x_e1edpt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .

* For creator of document
CONCATENATE c_ernam
dxvbak-ernam
INTO x_e1edpt2-tdline
SEPARATED BY space.
x_e1edpt2-tdformat = '*'.
x_edidd-sdata = x_e1edpt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
SELECT SINGLE tdlnr
INTO v_tdlnr
FROM tvro
WHERE route = dxvbap-route.
IF sy-subrc = 0.
SELECT SINGLE scacd
INTO v_scacd
FROM lfa1
WHERE lifnr = v_tdlnr.
CONCATENATE c_tdlnr
v_scacd
INTO x_e1edpt2-tdline
SEPARATED BY space.
x_e1edpt2-tdformat = '*'.
x_edidd-sdata = x_e1edpt2.
INSERT x_edidd INTO dint_edidd INDEX l_tabix .
ENDIF.

ENDDO.

No comments: