Uploaded by Li Mingfeng

New Text Document

advertisement
 FIND FIRST OCCURRENCE OF LV_DB_QUOTE IN LS_TAB-LINE.
IF SY-SUBRC NE 0.
CLEAR LS_UPLOAD_CHL.
SPLIT LS_TAB-LINE AT ','
INTO LS_UPLOAD_CHL-BSTNK " Sales Order No. / 销售单号
LS_UPLOAD_CHL-AUDAT " Sales Date / 销售订单日期YYYYMMDD
LS_UPLOAD_CHL-KUNNR " Customer Number / 渠道通用编号
LS_UPLOAD_CHL-NAME1 " Customer Name / 实际客户名称
LS_UPLOAD_CHL-CITY_STREET" Customer Adress / 实际客户地址
LS_UPLOAD_CHL-POSNR " No. / 序号
LS_UPLOAD_CHL-MATNR " SAP Article / 商品编号
LS_UPLOAD_CHL-ARKTX " Article Description / 商品描述
LS_UPLOAD_CHL-WERKS " Plant / 出货工厂
LS_UPLOAD_CHL-KWMENG " Quantity / 数量 vbap-kwmeng
LS_UPLOAD_CHL-KWERT " Sub Total Price / 销售小计价格 prcd_elements-kwert
LS_UPLOAD_CHL-VRKME " Sales Unit / 销售单位
LS_UPLOAD_CHL-PERC_DISC_YD02 " Percentage Discount
LS_UPLOAD_CHL-ABS_DISC_YD01 " absolute Discount
LS_UPLOAD_CHL-PSTYV " Item Category / 项目类别
LS_UPLOAD_CHL-REMARKS. " Header Remarks / 抬头文本备注
IF LS_UPLOAD_CHL-BSTNK IS INITIAL.
CONTINUE.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
EXPORTING
INPUT = LS_UPLOAD_CHL-VRKME
LANGUAGE = SY-LANGU
IMPORTING
OUTPUT = LS_UPLOAD_CHL-VRKME_IN
EXCEPTIONS
UNIT_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
LS_UPLOAD_CHL-VRKME_IN = LS_UPLOAD_CHL-VRKME.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
INPUT = LS_UPLOAD_CHL-MATNR
IMPORTING
OUTPUT = LS_UPLOAD_CHL-MATNR
* EXCEPTIONS
* LENGTH_ERROR = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = LS_UPLOAD_CHL-KUNNR
IMPORTING
OUTPUT = LS_UPLOAD_CHL-KUNNR.
APPEND LS_UPLOAD_CHL TO GT_UPLOAD_CHL.
ELSE. " handle comma
CLEAR: LT_RESULT_TAB, LV_START, LV_PREV_OFFSET, LT_WORK, LV_DB_QUOTE_FOUND .
LV_PREV_TXT = LS_TAB-LINE.
LV_FIRST_TIME = 'X'.
FIND ALL OCCURRENCES OF LV_COMMA IN LS_TAB-LINE RESULTS LT_RESULT_TAB.
LOOP AT LT_RESULT_TAB INTO LS_RESULT_TAB.
CLEAR LS_WORK.
IF LV_FIRST_TIME = 'X'.
CLEAR LV_FIRST_TIME.
LS_WORK-LINE = LS_TAB-LINE+0(LS_RESULT_TAB-OFFSET).
LS_WORK-NLENGTH = LS_RESULT_TAB-OFFSET.
ELSE.
LV_START = LV_PREV_OFFSET + 1.
LV_LEN = LS_RESULT_TAB-OFFSET - LV_START.
LS_WORK-LINE = LS_TAB-LINE+LV_START(LV_LEN).
LS_WORK-NLENGTH = LV_LEN.
ENDIF.
APPEND LS_WORK TO LT_WORK.
LV_PREV_OFFSET = LS_RESULT_TAB-OFFSET.
ENDLOOP.
IF SY-SUBRC = 0.
CLEAR LS_WORK.
LV_START = LV_PREV_OFFSET + 1.
LS_WORK-LINE = LS_TAB-LINE+LV_START.
APPEND LS_WORK TO LT_WORK.
ENDIF.
CLEAR LV_DB_QUOTE_FOUND .
LOOP AT LT_WORK INTO LS_WORK.
IF LS_WORK-LINE+0(1) = '"' AND LV_DB_QUOTE_FOUND <> 'X'.
LV_TXT_2 = LS_WORK-LINE.
LV_TXT_2+LS_WORK-NLENGTH(1) = ','.
LV_TXT = LV_TXT_2+1.
LV_DB_QUOTE_FOUND = 'X'.
LS_WORK-DELETE = 'X'.
ELSEIF LV_DB_QUOTE_FOUND = 'X'.
LV_LEN = STRLEN( LS_WORK-LINE ).
LV_LEN = LV_LEN - 1.
IF LV_LEN >= 0.
IF LS_WORK-LINE+LV_LEN(1) = '"'.
IF LV_LEN NE 0.
LV_TXT_2 = LS_WORK-LINE+0(LV_LEN).
CONCATENATE LV_TXT LV_TXT_2 INTO LV_TEMP_TXT.
LV_TXT = LV_TEMP_TXT.
ENDIF.
CLEAR LV_DB_QUOTE_FOUND.
LS_WORK-LINE = LV_TXT.
ELSE.
LV_TXT_2 = LS_WORK-LINE.
LV_TXT_2+LS_WORK-NLENGTH(1) = ','.
CONCATENATE LV_TXT LV_TXT_2 INTO LV_TEMP_TXT.
LV_TXT = LV_TEMP_TXT.
LS_WORK-DELETE = 'X'.
ENDIF.
ENDIF.
ENDIF.
MODIFY LT_WORK FROM LS_WORK.
ENDLOOP.
LOOP AT LT_WORK INTO LS_WORK.
IF LS_WORK-DELETE = 'X'.
DELETE LT_WORK.
ENDIF.
ENDLOOP.
CLEAR: LS_UPLOAD_CHL, LV_COUNTER.
LOOP AT LT_WORK INTO LS_WORK.
LV_COUNTER = LV_COUNTER + 1.
CASE LV_COUNTER.
WHEN 1.
LS_UPLOAD_CHL-BSTNK = LS_WORK-LINE.
WHEN 2.
LS_UPLOAD_CHL-AUDAT = LS_WORK-LINE.
WHEN 3.
LS_UPLOAD_CHL-KUNNR = LS_WORK-LINE.
WHEN 4.
LS_UPLOAD_CHL-NAME1 = LS_WORK-LINE.
WHEN 5.
LS_UPLOAD_CHL-CITY_STREET = LS_WORK-LINE.
WHEN 6.
LS_UPLOAD_CHL-POSNR = LS_WORK-LINE.
WHEN 7.
LS_UPLOAD_CHL-MATNR = LS_WORK-LINE.
WHEN 8.
LS_UPLOAD_CHL-ARKTX = LS_WORK-LINE.
WHEN 9.
LS_UPLOAD_CHL-WERKS = LS_WORK-LINE.
WHEN 10.
LS_UPLOAD_CHL-KWMENG = LS_WORK-LINE.
WHEN 11.
LS_UPLOAD_CHL-KWERT = LS_WORK-LINE.
WHEN 12.
LS_UPLOAD_CHL-VRKME = LS_WORK-LINE.
WHEN 13.
LS_UPLOAD_CHL-PERC_DISC_YD02 = LS_WORK-LINE.
WHEN 14.
LS_UPLOAD_CHL-ABS_DISC_YD01 = LS_WORK-LINE.
WHEN 15.
LS_UPLOAD_CHL-PSTYV = LS_WORK-LINE.
WHEN 16.
LS_UPLOAD_CHL-REMARKS = LS_WORK-LINE.
ENDCASE.
IF LS_UPLOAD_CHL-BSTNK IS INITIAL.
CONTINUE.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
EXPORTING
INPUT = LS_UPLOAD_CHL-VRKME
LANGUAGE = SY-LANGU
IMPORTING
OUTPUT = LS_UPLOAD_CHL-VRKME_IN
EXCEPTIONS
UNIT_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
LS_UPLOAD_CHL-VRKME_IN = LS_UPLOAD_CHL-VRKME.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
INPUT = LS_UPLOAD_CHL-MATNR
IMPORTING
OUTPUT = LS_UPLOAD_CHL-MATNR
* EXCEPTIONS
* LENGTH_ERROR = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = LS_UPLOAD_CHL-KUNNR
IMPORTING
OUTPUT = LS_UPLOAD_CHL-KUNNR.
APPEND LS_UPLOAD_CHL TO GT_UPLOAD_CHL.
ENDLOOP.
ENDIF.
ENDLOOP.
Download