FUNCTION ZRFC_WMS_READTEXT.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" VALUE(PARAMS) TYPE STRING OPTIONAL
*" TABLES
*" IT_LINE STRUCTURE ZTEXT_LINE OPTIONAL
*"----------------------------------------------------------------------
DATA: IL_TLINE LIKE TLINE OCCURS 0 WITH HEADER LINE.
DATA: IT_TLINE LIKE TLINE OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF IPARAM OCCURS 10,
VBELN TYPE LIPS-VBELN ,
END OF IPARAM.
DATA: L_AUART LIKE VBAK-AUART, "销售订单类型
B_TYPE.
SPLIT PARAMS AT ',' INTO TABLE IPARAM.
DATA : S(3000),
LFART LIKE LIKP-LFART,
* T_KUNNR LIKE LIKP-KUNNR,
* T_ADRNR LIKE KNA1-ADRNR,
* T_STREET LIKE ADRC-STREET,
IP_VBELN LIKE LIPS-VBELN,
T_EBELN LIKE THEAD-TDNAME,
T_VBELN LIKE THEAD-TDNAME.
*-----------CHA JWY_20170811
SORT IPARAM.
*-----------CHA JWY_20170811
LOOP AT IPARAM.
* T_STREET = ''.
IP_VBELN = IPARAM-VBELN.
PERFORM F_ADD_ZERO USING IP_VBELN .
T_VBELN = IP_VBELN.
CLEAR IL_TLINE[].
CLEAR IL_TLINE.
* CLEAR: LFART,T_EBELN.
* SELECT SINGLE LFART KUNNR INTO (LFART,T_KUNNR) FROM LIKP
* WHERE VBELN = T_VBELN.
* SELECT SINGLE ADRNR INTO T_ADRNR FROM KNA1 WHERE KUNNR = T_KUNNR.
* SELECT SINGLE STREET INTO T_STREET FROM ADRC
* WHERE ADDRNUMBER = T_ADRNR.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = '001'
LANGUAGE = '1'
NAME = T_VBELN
OBJECT = 'VBBK'
* IMPORTING
* HEADER = HTEXT
TABLES
LINES = IL_TLINE
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
DATA: T_VTWEG TYPE VTWEG.
CLEAR T_VTWEG.
IF IL_TLINE[] IS INITIAL.
SELECT SINGLE VGBEL VTWEG
INTO (T_EBELN,T_VTWEG)
FROM LIPS
WHERE VBELN = T_VBELN .
* ADD BY LH 获取销售订单类型 和销售渠道
*当订单类型 = ZOR或者ZOR9或者RE或者ZPRD,渠道 = 10 或者 12或者13或者30时
CLEAR B_TYPE.
CLEAR L_AUART.
IF T_VTWEG = '10' OR T_VTWEG = '12'
OR T_VTWEG = '13' OR T_VTWEG = '30'.
SELECT SINGLE AUART "获取销售订单类型
INTO L_AUART
FROM VBAK
WHERE VBELN = T_EBELN.
IF L_AUART = 'ZOR' OR L_AUART = 'ZOR9'
OR L_AUART = 'RE' OR L_AUART = 'ZPRD'.
B_TYPE = 'X'.
ENDIF.
ENDIF.
DATA: T_ID LIKE THEAD-TDID.
CLEAR T_ID.
IF T_EBELN+0(2) = '00'.
IF T_VTWEG = '18'.
DATA: I TYPE INT1.
I = 4.
DO 6 TIMES.
MOVE I TO T_ID.
PERFORM F_ADD_ZERO USING T_ID.
CLEAR: IT_TLINE[],IT_TLINE. "ADD BY LH 20180824
CALL FUNCTION 'READ_TEXT' "订单
EXPORTING
CLIENT = SY-MANDT
ID = T_ID
LANGUAGE = '1'
NAME = T_EBELN
OBJECT = 'VBBK'
* IMPORTING
* HEADER = HTEXT
TABLES
LINES = IT_TLINE
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
APPEND LINES OF IT_TLINE TO IL_TLINE.
CLEAR IT_TLINE.
IT_TLINE-TDLINE = CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
APPEND IT_TLINE TO IL_TLINE.
I = I + 1.
ENDDO.
*ADD BY LH 20180507 每个订单带收货人信息(收货人、收货电话、收货地址)
ELSEIF B_TYPE = 'X'.
CLEAR: IT_TLINE[],IT_TLINE. "ADD BY LH 20180824
CALL FUNCTION 'READ_TEXT' "订单 收件地址
EXPORTING
CLIENT = SY-MANDT
ID = '0004'
LANGUAGE = '1'
NAME = T_EBELN
OBJECT = 'VBBK'
* IMPORTING
* HEADER = HTEXT
TABLES
LINES = IT_TLINE
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
APPEND LINES OF IT_TLINE TO IL_TLINE.
CLEAR IT_TLINE.
IT_TLINE-TDLINE = CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
APPEND IT_TLINE TO IL_TLINE.
CLEAR: IT_TLINE[],IT_TLINE. "ADD BY LH 20180824
CALL FUNCTION 'READ_TEXT' "订单 收件人
EXPORTING
CLIENT = SY-MANDT
ID = '0006'
LANGUAGE = '1'
NAME = T_EBELN
OBJECT = 'VBBK'
* IMPORTING
* HEADER = HTEXT
TABLES
LINES = IT_TLINE
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
APPEND LINES OF IT_TLINE TO IL_TLINE.
CLEAR IT_TLINE.
IT_TLINE-TDLINE = CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
APPEND IT_TLINE TO IL_TLINE.
CLEAR: IT_TLINE[],IT_TLINE. "ADD BY LH 20180824
CALL FUNCTION 'READ_TEXT' "订单 收件人电话
EXPORTING
CLIENT = SY-MANDT
ID = '0007'
LANGUAGE = '1'
NAME = T_EBELN
OBJECT = 'VBBK'
* IMPORTING
* HEADER = HTEXT
TABLES
LINES = IT_TLINE
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
APPEND LINES OF IT_TLINE TO IL_TLINE.
CLEAR IT_TLINE.
IT_TLINE-TDLINE = CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
APPEND IT_TLINE TO IL_TLINE.
ELSE.
T_ID = '0001'.
CALL FUNCTION 'READ_TEXT' "订单
EXPORTING
CLIENT = SY-MANDT
ID = T_ID
LANGUAGE = '1'
NAME = T_EBELN
OBJECT = 'VBBK'
* IMPORTING
* HEADER = HTEXT
TABLES
LINES = IL_TLINE
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
ENDIF.
ELSE.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = 'F01'
LANGUAGE = '1'
NAME = T_EBELN
OBJECT = 'EKKO'
* IMPORTING
* HEADER = HTEXT
TABLES
LINES = IL_TLINE
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
ENDIF.
ENDIF.
S = ''.
**-----------CHA JWY_20170811
* SORT IL_TLINE.
**-----------CHA JWY_20170811
LOOP AT IL_TLINE.
CONCATENATE S IL_TLINE-TDLINE INTO S.
ENDLOOP.
IT_LINE-TNO_LINE = IPARAM-VBELN.
* IF S = T_STREET .
* IT_LINE-TDLINE = ''.
* ELSE.
IT_LINE-TDLINE = S.
* ENDIF.
DATA: V_MATNR TYPE MATNR,V_ABCIN(1),V_MAABC(1).
CLEAR: V_MATNR,V_ABCIN.
SELECT SINGLE MATNR INTO V_MATNR FROM LIPS WHERE VBELN = IP_VBELN.
SELECT SINGLE ABCIN MAABC INTO (V_ABCIN,V_MAABC) FROM MARC WHERE WERKS = '6000' AND MATNR = V_MATNR.
IF V_ABCIN = 'S'.
* CONCATENATE '配件-' IT_LINE-TDLINE INTO IT_LINE-TDLINE .
IF V_MAABC = 'L'.
CONCATENATE '配件快递-' IT_LINE-TDLINE INTO IT_LINE-TDLINE .
ELSE.
CONCATENATE '配件-' IT_LINE-TDLINE INTO IT_LINE-TDLINE .
ENDIF.
ENDIF.
SELECT MATNR INTO V_MATNR FROM ZSDA35 WHERE MATNR = V_MATNR.
SELECT SINGLE KUNNR INTO S FROM LIKP WHERE VSTEL = '1002' AND VBELN = IP_VBELN.
IF SY-SUBRC = 0.
PERFORM F_CUT_ZERO USING S.
CONCATENATE S '-' IT_LINE-TDLINE INTO IT_LINE-TDLINE .
ENDIF.
ENDSELECT.
APPEND IT_LINE.
CLEAR IT_LINE.
ENDLOOP.
* IF SY-SUBRC <> 0.
* ELSE.
* LOOP AT IL_TLINE.
* IF IL_TLINE-TDLINE NE ''.
* WRITE: / IL_TLINE-TDLINE.
* ENDIF.
* ENDLOOP.
* ENDIF.
ENDFUNCTION.