ZSDR017-客户订货价格和库存

*----------------------------------------------------------------------
*ZSDR017-客户订货价格和库存
*----------------------------------------------------------------------

REPORT ZSDR017 NO STANDARD PAGE HEADING
MESSAGE-ID ZSD
LINE-SIZE 132
LINE-COUNT 65.

*----------------------------------------------------------------------
* TYPE-POOLS
*----------------------------------------------------------------------
TYPE-POOLS: SLIS, "ALV
TRUXS.

*----------------------------------------------------------------------
* TABLES/Structure
*----------------------------------------------------------------------
TABLES: MARA,
MARM,
T179,
KONP,
MARD,
KNA1,
VBAK,
TWVK,
RV130.
" zstatu ZSD008 ZSD13

*----------------------------------------------------------------------
* DAGTA /Internal table
*----------------------------------------------------------------------
*&(contain all)
DATA: BEGIN OF IT_DATA OCCURS 0,
MATNR LIKE MARA-MATNR,"kunnr ->model(s) ->matnr(s)
PRDHA LIKE MARA-PRDHA,"产品层次
ZMDNM LIKE MARA-ZMDNM,"型号
UMREZ LIKE MARM-UMREZ,"单位
MATKL LIKE MARA-MATKL,"品牌
UMREZ1(10) TYPE C, "单位
ZONGL(200) TYPE C, "总类别
FENEL(200) TYPE C, "分类别
STATU(50) TYPE C, "料状态
XHTXT(100) TYPE C, "型号描述
XHTXT1(100) TYPE C, "Internal comment
KBETR LIKE KONP-KBETR,"价格:
KCNGE LIKE MARD-LABST,"现库存
DINSH LIKE MARD-LABST,"default 0,供用户输入
LAST1 LIKE MARD-LABST,"最近一次订单数
LAST2 LIKE MARD-LABST,"倒数第二次订单数
LAST3 LIKE MARD-LABST,"倒数第三次订单数
KONWA LIKE KONP-KONWA,

END OF IT_DATA.
DATA: WA_DATA LIKE IT_DATA.

*&PDF:
DATA: BEGIN OF IT_DATAP OCCURS 0,
KUNNR LIKE KNA1-KUNNR,"kunnr
ZMDNM LIKE MARA-ZMDNM,"型号 "Model to get matkl to decide log.
MATKL LIKE MARA-MATKL,"brand

ZONGL(200) TYPE C, "总类别 Main Category
FENEL(200) TYPE C, "分类别 Sub Category
STATU(50) TYPE C, "料状态 Status
UMREZ1(10) TYPE C, "单位 MC Qty
XHTXT(50) TYPE C, "型号描述 Item text
XHTXT1(100) TYPE C, "Internal comment Prod Subhead
*&CHAGNE ON 20140214.
KBETR TYPE STRING,
* KBETR LIKE KONP-KBETR,"价格:US$
KCNGE LIKE MARD-LABST,"现库存 Current Availabile fixed value
KCSHU(50) TYPE C, "库存 district
END OF IT_DATAP.

*&CSV:
DATA: BEGIN OF IT_DATAC OCCURS 0,
STATU(50) TYPE C, "料状态
ZONGL(200) TYPE C, "总类别 Main Category
FENEL(200) TYPE C, "分类别 Sub Category
UMREZ1(10) TYPE C, "单位 MC Qty

ZMDNM LIKE MARA-ZMDNM,"型号 Model Name
KCNGE LIKE MARD-LABST,"现库存 Current Available
KCSHU(50) TYPE C, "库存
DINSH LIKE MARD-LABST,"default 0,供用户输入 Ordered Qty
LAST1 LIKE MARD-LABST,"最近一次订单数 Last-1 Ordered Qty
LAST2 LIKE MARD-LABST,"倒数第二次订单数 Last-1 Ordered Qty
LAST3 LIKE MARD-LABST,"倒数第三次订单数 Last-1 Ordered Qty
END OF IT_DATAC.

DATA:ITAB1 TYPE TRUXS_T_TEXT_DATA,
WA_ITAB1 LIKE LINE OF ITAB1.

*----------------------------------------------------------------------
* Data parameters for alv report use
*----------------------------------------------------------------------
DATA: G_PROGRAM TYPE SY-REPID,
GW_LAYOUT TYPE SLIS_LAYOUT_ALV,
GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
GT_EVENT TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT,
TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.

DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA L_LEN TYPE I.

CONSTANTS:ER_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE ‘TOP_OF_PAGE‘.
DATA:G_FILE LIKE RLGRAP-FILENAME.
DATA:S_FILE LIKE RLGRAP-FILENAME.
DATA:LINE(1000) TYPE C.

*======================================================================
* SELECTION-SCREEN
*======================================================================
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.

PARAMETERS: P_KUNNR LIKE KNA1-KUNNR OBLIGATORY,
P_KSCHL LIKE TWVK-KSCHL DEFAULT ‘ZP01‘.

*S_KUNNR FOR KNA1-KUNNR,
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR. "NO-DISPLAY.
SELECT-OPTIONS: S_VKORG FOR VBAK-VKORG DEFAULT ‘1100‘,
S_VTWEG FOR VBAK-VTWEG DEFAULT ‘10‘.

PARAMETERS: P_ERDAT LIKE MARA-ERSDA DEFAULT SY-DATUM.

SELECTION-SCREEN SKIP 1.

PARAMETERS:P_SEFILE LIKE RLGRAP-FILENAME DEFAULT ‘/mnt/ReceiveFromMG/Report/‘.

SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-002.
PARAMETERS: RB_PDF RADIOBUTTON GROUP R1 DEFAULT ‘X‘,
RB_CSV RADIOBUTTON GROUP R1,
RB_ALV RADIOBUTTON GROUP R1.

SELECTION-SCREEN END OF BLOCK BLK2.

SELECTION-SCREEN END OF BLOCK BLK1.

*----------------------------------------------------------------------
* INITIALIZATION
*----------------------------------------------------------------------
INITIALIZATION.

* 初始化数据
PERFORM FRM_INITIAL.

*----------------------------------------------------------------------
* AT SELECTION-SCREEN
*----------------------------------------------------------------------
AT SELECTION-SCREEN.

* 权限检查部分
PERFORM FRM_CHECK_AUTHOR.

*======================================================================
* MAIN PROGRAM
*======================================================================
* START-OF-SELECTION
*----------------------------------------------------------------------
START-OF-SELECTION.
*&获取数据

PERFORM FRM_GET_DATA.

CASE ‘X‘.

WHEN RB_PDF.
CHECK IT_DATAP[] IS NOT INITIAL.
PERFORM FRM_PDF_OUT.

WHEN RB_CSV.
CHECK IT_DATAC[] IS NOT INITIAL.
PERFORM FRM_CSV_OUT.

WHEN RB_ALV.
*&ALV展示输出
CHECK IT_DATA[] IS NOT INITIAL.
PERFORM FRM_ALV_OUTPUT.

WHEN OTHERS.

ENDCASE.

*----------------------------------------------------------------------
* END-OF-SELECTION
*----------------------------------------------------------------------

*&---------------------------------------------------------------------*
*& Form FRM_INITIAL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_INITIAL.

ENDFORM. " FRM_INITIAL

*&---------------------------------------------------------------------*
*& Form FRM_CHECK_AUTHOR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_CHECK_AUTHOR.

ENDFORM. " FRM_CHECK_AUTHOR

*&---------------------------------------------------------------------*
*& Form frm_get_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_GET_DATA .

DATA:BEGIN OF LT_ZSTATU OCCURS 0, ZMDNM
LIKE ZT0001-ZMDNM, STATU
(50) TYPE C, "料状态
END OF LT_ZSTATU.
DATA:BEGIN OF LT_KEHU OCCURS 0, KUNNR
LIKE KNA1-KUNNR, MATNR
LIKE MARA-MATNR, MATN1
LIKE MARA-MATNR, ZMDNM
LIKE MARA-ZMDNM,
END OF LT_KEHU.
DATA:BEGIN OF LT_BANB OCCURS 0, KUNNR
LIKE KNVV-KUNNR, KVGR1
LIKE ZSD008-MATVD, KVGR2
LIKE ZSD008-MATVD, KVGR3
LIKE ZSD008-MATVD, KVGR4
LIKE ZSD008-MATVD, KVGR5
LIKE ZSD008-MATVD,
END OF LT_BANB.
DATA:BEGIN OF LT_KOTG OCCURS 0, KSCHL
LIKE KOTG001-KSCHL, KUNNR
LIKE KOTG001-KUNNR, MATNR
LIKE KOTG001-MATNR,
END OF LT_KOTG.
DATA:G_TABIX TYPE SY-TABIX.

DATA:BEGIN OF LT_ZSD008 OCCURS 0, MATVN
LIKE ZSD008-MATVN, MATVD
LIKE ZSD008-MATVD,
END OF LT_ZSD008.

DATA:BEGIN OF LT_MARD OCCURS 0, MATNR
LIKE MARD-MATNR, LABST
LIKE MARD-LABST,
END OF LT_MARD.
DATA:BEGIN OF LT_MARD3 OCCURS 0, MATNR
LIKE MARD-MATNR, LABST
LIKE MARD-LABST,"未交 qty
END OF LT_MARD3.

DATA: BEGIN OF LT_A004 OCCURS 0, KSCHL
LIKE A004-KSCHL, MWSKZ
LIKE A003-MWSKZ, MATNR
LIKE A004-MATNR, KBETR
LIKE KONP-KBETR,
END OF LT_A004.
DATA: BEGIN OF LT_A005 OCCURS 0, MATNR
LIKE A005-MATNR, KNUMH
LIKE A005-KNUMH, KBETR
LIKE KONP-KBETR, KMEIN
LIKE KONP-KMEIN, KONWA
LIKE KONP-KONWA,
END OF LT_A005.
DATA:BEGIN OF LT_KONP OCCURS 0, KNUMH
LIKE KONP-KNUMH, KBETR
LIKE KONP-KBETR, KMEIN
LIKE KONP-KMEIN, KONWA
LIKE KONP-KONWA,
END OF LT_KONP.

DATA: LV_NAME LIKE THEAD-TDNAME, LT_LINE
LIKE STANDARD TABLE OF TLINE, LWA_LINE
LIKE LINE OF LT_LINE, LV_TEXT
TYPE STRING.

DATA: BEGIN OF LT_ZSD13 OCCURS 0, VBELN
LIKE ZSD13-VBELN, POSNR
LIKE ZSD13-POSNR, MATNR
LIKE ZSD13-MATNR, KWMENG
LIKE ZSD13-KWMENG, "订单数量 RFMNGM
LIKE ZSD13-RFMNGM, "确认的数量
*BMENG LIKE ZSD13-BMENG, "确认的数量 ERDAT
LIKE ZSD13-ERDAT,
END OF LT_ZSD13.

DATA: BEGIN OF LT_ZSD131 OCCURS 0, MATNR
LIKE VBAP-MATNR, WJENG
LIKE VBAP-KWMENG,"未交 qty
END OF LT_ZSD131.

DATA: BEGIN OF LT_VBAK OCCURS 0, MATNR
LIKE VBAP-MATNR, VBELN
LIKE VBAK-VBELN, ERDAT
LIKE VBAK-ERDAT, ERZET
LIKE VBAK-ERZET, VBTYP
LIKE VBAK-VBTYP, KUNNR
LIKE VBAK-KUNNR,
END OF LT_VBAK, WA_VBAK
LIKE LT_VBAK.

DATA: BEGIN OF LT_VBAK1 OCCURS 0, MATNR
LIKE VBAP-MATNR, VBELN
LIKE VBAK-VBELN, VBTYP
LIKE VBAK-VBTYP, KUNNR
LIKE VBAK-KUNNR, KWMENG
LIKE VBAP-KWMENG,
INDEX TYPE SY-TABIX,
END OF LT_VBAK1.
DATA:L_KBETR TYPE STRING, L_KONWA
TYPE STRING.

*&G1.1.kunnr get matnr
SELECT A~KUNAG AS KUNNR B
~MATNR
INTO TABLE LT_KEHU
FROM KOTG951 AS A
JOIN MVKE AS B
ON A~ZZMVGR2 EQ B~MVGR2
WHERE A~KUNAG EQ P_KUNNR
AND A~DATBI GE P_ERDAT
AND A~DATAB LE P_ERDAT
AND B~VKORG IN S_VKORG
AND B~VTWEG IN S_VTWEG
*&->CHANGE
AND B~MATNR IN S_MATNR.

*&-> use for test D300
IF SY-MANDT NE ‘300‘.
IF SY-SUBRC NE 0.
MESSAGE S001 DISPLAY LIKE ‘W‘.
EXIT.
ENDIF.
ENDIF.
DELETE ADJACENT DUPLICATES FROM LT_KEHU COMPARING ALL FIELDS.

*&G1.2.kunnr get kvgr1 ->kvgr5(versions) delete
SELECT KUNNR KVGR1 KVGR2 KVGR3 KVGR4 KVGR5
INTO TABLE LT_BANB
FROM KNVV
WHERE KUNNR EQ P_KUNNR
AND VKORG IN S_VKORG
AND VTWEG IN S_VTWEG.

*&G1.3 get delete condition(version code) matnr+8(2) compare
SELECT MATVN MATVD

INTO TABLE LT_ZSD008
FROM ZSD008
FOR ALL ENTRIES IN LT_BANB
WHERE MATVD EQ LT_BANB-KVGR1
OR MATVD EQ LT_BANB-KVGR2
OR MATVD EQ LT_BANB-KVGR3
OR MATVD EQ LT_BANB-KVGR4
OR MATVD EQ LT_BANB-KVGR5.
**&G1.4.delete by version:
* LOOP AT LT_KEHU.
* G_TABIX = SY-TABIX.
* LT_KEHU-MATN1 = LT_KEHU-MATNR+7(2).
* READ TABLE LT_ZSD008 WITH KEY MATVN = LT_KEHU-MATN1.
* IF SY-SUBRC NE 0.
* DELETE LT_KEHU INDEX G_TABIX.
* CLEAR LT_KEHU.
* ELSE.
* MODIFY LT_KEHU TRANSPORTING MATN1.
* CLEAR LT_KEHU.
* ENDIF.
**MODIFY LT_KEHU TRANSPORTING MATN1.
**SELECT SINGLE ZMDNM
* ENDLOOP.

*&->CHANGE BY VN0037 ON 20130214.
*&G1.7.delete matnr
LOOP AT LT_KEHU. G_TABIX
= SY-TABIX.
*&2.delete not end with ‘10‘.
IF LT_KEHU-MATNR+13(2) NE ‘10‘.
DELETE LT_KEHU INDEX G_TABIX.
CLEAR:LT_KEHU.
CONTINUE.
ENDIF.
*&1.delete by version: LT_KEHU
-MATN1 = LT_KEHU-MATNR+7(2).
READ TABLE LT_ZSD008 WITH KEY MATVN = LT_KEHU-MATN1.
IF SY-SUBRC NE 0.
DELETE LT_KEHU INDEX G_TABIX.
CLEAR LT_KEHU.
CONTINUE.
ENDIF.
MODIFY LT_KEHU TRANSPORTING MATN1.
CLEAR LT_KEHU.

ENDLOOP.

*&G1.5. kunnr ‘ZDIV‘ get useful matnr
SELECT KSCHL KUNNR MATNR

INTO TABLE LT_KOTG
FROM KOTG001
WHERE KSCHL IN (‘ZDIV‘,‘B001‘)
AND KUNNR EQ P_KUNNR
AND DATAB LE P_ERDAT
AND DATBI GE P_ERDAT.

*&G1.6.add‘ZDIV‘ type, delete‘B001’type->Last kunnr matnr.
LOOP AT LT_KOTG." WHERE KSCHL EQ ‘ZDIV‘.
*& +‘ZDIV‘.
IF LT_KOTG-KSCHL EQ ‘ZDIV‘. LT_KEHU
-KUNNR = LT_KOTG-KUNNR. LT_KEHU
-MATNR = LT_KOTG-MATNR.
APPEND LT_KEHU.
ELSE.
*& - ‘B001‘.
DELETE LT_KEHU WHERE MATNR EQ LT_KOTG-MATNR.
ENDIF.
ENDLOOP.

**&G1.7.delete matnr
* LOOP AT LT_KEHU.
* G_TABIX = SY-TABIX.
**&2.delete not end with ‘10‘.
* IF LT_KEHU-MATNR+13(2) NE ‘10‘.
* DELETE LT_KEHU INDEX G_TABIX.
* CLEAR:LT_KEHU.
* CONTINUE.
* ENDIF.
**&1.delete by version:
* LT_KEHU-MATN1 = LT_KEHU-MATNR+7(2).
* READ TABLE LT_ZSD008 WITH KEY MATVN = LT_KEHU-MATN1.
* IF SY-SUBRC NE 0.
* DELETE LT_KEHU INDEX G_TABIX.
* CLEAR LT_KEHU.
* CONTINUE.
* ENDIF.
* MODIFY LT_KEHU TRANSPORTING MATN1.
* CLEAR LT_KEHU.
*
* ENDLOOP.

*&G2.1 Matnr geted to find mara + MODLE
*&->test for D300.
IF LT_KEHU[] IS NOT INITIAL.

SELECT A~MATNR A
~PRDHA A
~ZMDNM B
~UMREZ A
~MATKL
INTO TABLE IT_DATA
FROM MARA AS A
JOIN MARM AS B
ON A~MATNR EQ B~MATNR
FOR ALL ENTRIES IN LT_KEHU
WHERE A~MATNR EQ LT_KEHU-MATNR
AND B~MEINH EQ ‘KAR‘.
ELSE.

SELECT A~MATNR A
~PRDHA A
~ZMDNM B
~UMREZ
INTO CORRESPONDING FIELDS OF TABLE IT_DATA
FROM MARA AS A
JOIN MARM AS B
ON A~MATNR EQ B~MATNR
WHERE A~MATNR IN S_MATNR
AND B~MEINH EQ ‘KAR‘. "

ENDIF.

DESCRIBE TABLE IT_DATA LINES L_LEN.
IF L_LEN EQ 0.
MESSAGE S001 WITH ‘No data!‘ DISPLAY LIKE ‘W‘.
EXIT.
ENDIF.

SORT IT_DATA BY MATNR.

*&G2.2.Get model statu
SELECT ZMDNM "STATU
INTO TABLE LT_ZSTATU
FROM ZT0001
FOR ALL ENTRIES IN IT_DATA
*&->change
*WHERE ZMDNM EQ IT_DATA-ZMDNM
WHERE ZMDNM EQ IT_DATA-ZMDNM
AND ZDATE GE P_ERDAT.

* SELECT ZMDNM "STATU
* INTO TABLE LT_ZSTATU
* FROM ZSTATU
* SELECT A~MATNR
* B~KBETR
* INTO TABLE LT_A004
* FROM A004 AS A
* JOIN KONP AS B
* ON A~KNUMH EQ B~KNUMH
* AND A~KSCHL EQ B~KSCHL
* WHERE A~KSCHL EQ p_KSCHL
* AND A~VKORG IN S_VKORG
* AND A~VTWEG IN S_VTWEG
* AND A~DATAB LE P_ERDAT
*& A006.

IF IT_DATA[] IS NOT INITIAL.
*&G2.3 KUNNR MATNR GET KUNMH :得条件记录号
SELECT MATNR KNUMH
INTO TABLE LT_A005
FROM A005
FOR ALL ENTRIES IN IT_DATA
WHERE KAPPL EQ ‘V‘
AND KSCHL EQ P_KSCHL
AND VKORG IN S_VKORG
AND VTWEG IN S_VTWEG
AND KUNNR EQ P_KUNNR
AND MATNR EQ IT_DATA-MATNR
AND DATBI GE P_ERDAT
AND DATAB LE P_ERDAT.

DATA:LV_KONDA LIKE KNVV-KONDA.
CLEAR LV_KONDA.
SELECT SINGLE KONDA
INTO LV_KONDA
FROM KNVV
WHERE KUNNR EQ P_KUNNR.

SELECT MATNR KNUMH
APPENDING TABLE LT_A005
FROM A032
FOR ALL ENTRIES IN IT_DATA
WHERE KAPPL EQ ‘V‘
AND KSCHL EQ P_KSCHL
AND VKORG IN S_VKORG
AND VTWEG IN S_VTWEG
AND KONDA EQ LV_KONDA
AND MATNR EQ IT_DATA-MATNR
AND DATBI GE P_ERDAT
AND DATAB LE P_ERDAT.

ENDIF.

IF SY-SUBRC EQ 0.
*&G2.4 matnr get kbetr.
SELECT KNUMH KBETR KMEIN
*&CHAGNE ON 20140214. KONWA

INTO TABLE LT_KONP
FROM KONP
FOR ALL ENTRIES IN LT_A005
WHERE KNUMH EQ LT_A005-KNUMH
AND KSCHL EQ P_KSCHL
AND KOPOS EQ ‘1‘.
SORT LT_KONP BY KNUMH.
ENDIF.

*&G2.5 get matnr kbetr.
LOOP AT LT_A005.
READ TABLE LT_KONP WITH KEY KNUMH = LT_A005-KNUMH BINARY SEARCH.
IF SY-SUBRC EQ 0. LT_A005
-KBETR = LT_KONP-KBETR. LT_A005
-KMEIN = LT_KONP-KMEIN. LT_A005
-KONWA = LT_KONP-KONWA.

ENDIF.
MODIFY LT_A005.
ENDLOOP.

SORT LT_A005 BY MATNR.

*&G3.1 Get kucun
*& 是否存在负库存,?
SELECT MATNR LABST

INTO TABLE LT_MARD
FROM MARD
FOR ALL ENTRIES IN IT_DATA
WHERE MATNR EQ IT_DATA-MATNR
AND ( WERKS EQ ‘1100‘ AND LGORT EQ ‘1100‘ OR LGORT EQ ‘1181‘
OR ( WERKS EQ ‘3300‘ AND LGORT EQ ‘3351‘ OR LGORT EQ ‘3352‘ OR LGORT EQ ‘3353‘ ) ).

*&G3.2. get matnr labst
LOOP AT LT_MARD.
MOVE-CORRESPONDING LT_MARD TO LT_MARD3.
COLLECT LT_MARD3.
ENDLOOP.

SORT LT_MARD3 BY MATNR.

*&G3.3 zsd13 open so-aty (根据matnr 已做好 car 和pc 转换) order-qty quren-qyr
SELECT A~VBELN A
~POSNR A
~MATNR A
~KWMENG"订单数量 A
~RFMNGM"确认数量 A
~ERDAT "创建日期
INTO TABLE LT_ZSD13
FROM ZSD13 AS A
JOIN VBAK AS B
ON A~VBELN EQ B~VBELN
FOR ALL ENTRIES IN IT_DATA
WHERE A~MATNR EQ IT_DATA-MATNR
*&->change
* AND A~KUNNR EQ P_KUNNR
AND B~VBTYP EQ ‘C‘.

*&G3.4. get open-qty
LOOP AT LT_ZSD13. LT_ZSD131
-MATNR = LT_ZSD13-MATNR. LT_ZSD131
-WJENG = LT_ZSD13-KWMENG - LT_ZSD13-RFMNGM.
COLLECT LT_ZSD131.
ENDLOOP.
SORT LT_ZSD131 BY MATNR.

*&G4.1 kunnr -> vbeln
SELECT B~MATNR A
~VBELN A
~ERDAT A
~ERZET A
~VBTYP"凭证类别 AUART "销售凭证类型 A
~KUNNR
INTO TABLE LT_VBAK
FROM VBAK AS A
JOIN VBAP AS B
ON A~VBELN EQ B~VBELN
FOR ALL ENTRIES IN IT_DATA

WHERE A~KUNNR EQ P_KUNNR
AND A~VKORG IN S_VKORG
AND A~VTWEG IN S_VTWEG
AND A~VBTYP EQ ‘C‘ "订单 -》‘H’退货
AND B~MATNR EQ IT_DATA-MATNR.

SORT LT_VBAK BY MATNR VBELN DESCENDING.

DATA: LV_CNT TYPE I, LV_MATNR
TYPE MARA-MATNR.

LOOP AT LT_VBAK.
*&G4.2 get vbeln matnr kwmeng
* 得到订单数量是否要考虑 kunnr + matnr.
* MOVE LT_VBAK TO WA_VBAK.
IF LV_MATNR EQ ‘‘. LV_MATNR
= LT_VBAK-MATNR. LV_CNT
= ‘1‘. LT_VBAK1
-INDEX = LV_CNT. LT_VBAK1
-MATNR = LT_VBAK-MATNR. LT_VBAK1
-VBELN = LT_VBAK-VBELN. LT_VBAK1
-VBTYP = LT_VBAK-VBTYP. LT_VBAK1
-KUNNR = LT_VBAK-KUNNR.
SELECT SINGLE SUM( KWMENG )
INTO LT_VBAK1-KWMENG
FROM VBAP
WHERE VBELN EQ LT_VBAK-VBELN
AND MATNR EQ LT_VBAK-MATNR.

ELSE.

IF LV_MATNR = LT_VBAK-MATNR. LV_CNT
= LV_CNT + 1. LT_VBAK1
-INDEX = LV_CNT. LT_VBAK1
-MATNR = LT_VBAK-MATNR. LT_VBAK1
-VBELN = LT_VBAK-VBELN. LT_VBAK1
-VBTYP = LT_VBAK-VBTYP. LT_VBAK1
-KUNNR = LT_VBAK-KUNNR.
SELECT SINGLE SUM( KWMENG )
INTO LT_VBAK1-KWMENG
FROM VBAP
WHERE VBELN EQ LT_VBAK-VBELN
AND MATNR EQ LT_VBAK-MATNR.

IF LV_CNT GT 3.
CONTINUE.
ENDIF.

ELSE. LV_MATNR
= LT_VBAK-MATNR. LV_CNT
= 1. LT_VBAK1
-INDEX = LV_CNT. LT_VBAK1
-MATNR = LT_VBAK-MATNR. LT_VBAK1
-VBELN = LT_VBAK-VBELN. LT_VBAK1
-VBTYP = LT_VBAK-VBTYP. LT_VBAK1
-KUNNR = LT_VBAK-KUNNR.
SELECT SINGLE SUM( KWMENG )
INTO LT_VBAK1-KWMENG
FROM VBAP
WHERE VBELN EQ LT_VBAK-VBELN
AND MATNR EQ LT_VBAK-MATNR.
ENDIF.

ENDIF.

APPEND LT_VBAK1.

ENDLOOP.

SORT LT_VBAK1 BY MATNR INDEX.

**&G5.Get us from knop.
LOOP AT IT_DATA.
*&L1.GET PRODH name.
SELECT SINGLE VTEXT
INTO IT_DATA-ZONGL
FROM T179T
WHERE SPRAS EQ SY-LANGU
AND PRODH EQ IT_DATA-PRDHA+0(4).
SELECT SINGLE VTEXT
INTO IT_DATA-FENEL
FROM T179T
WHERE SPRAS EQ SY-LANGU
AND PRODH EQ IT_DATA-PRDHA+0(10). LV_NAME

= IT_DATA-MATNR.
*&L2.Get TXT for model descibe
CALL FUNCTION ‘READ_TEXT‘
EXPORTING
CLIENT = SY-MANDT
ID = ‘GRUN‘ "P_TEXTID
LANGUAGE = SY-LANGU NAME
= LV_NAME OBJECT
= ‘MATERIAL‘
TABLES
LINES = LT_LINE
EXCEPTIONS
ID = 1
LANGUAGE = 2 NAME
= 3 NOT_FOUND
= 4 OBJECT
= 5 REFERENCE_CHECK
= 6 WRONG_ACCESS_TO_ARCHIVE
= 7
OTHERS = 8.

IF SY-SUBRC EQ 0.
LOOP AT LT_LINE INTO LWA_LINE.
CONCATENATE LWA_LINE-TDLINE LV_TEXT INTO LV_TEXT.
ENDLOOP. IT_DATA
-XHTXT = LV_TEXT.
REPLACE ‘<(>&<)>‘ IN IT_DATA-XHTXT WITH ‘&‘.
CLEAR:LT_LINE[], LT_LINE, LV_TEXT.
ENDIF.

*&L3.Get long txt.
CALL FUNCTION ‘READ_TEXT‘
EXPORTING
CLIENT = SY-MANDT
ID = ‘IVER‘ "P_TEXTID
LANGUAGE = SY-LANGU NAME
= LV_NAME OBJECT
= ‘MATERIAL‘
TABLES
LINES = LT_LINE
EXCEPTIONS
ID = 1
LANGUAGE = 2 NAME
= 3 NOT_FOUND
= 4 OBJECT
= 5 REFERENCE_CHECK
= 6 WRONG_ACCESS_TO_ARCHIVE
= 7
OTHERS = 8.

IF SY-SUBRC EQ 0.
LOOP AT LT_LINE INTO LWA_LINE.
CONCATENATE LWA_LINE-TDLINE LV_TEXT INTO LV_TEXT.
ENDLOOP. IT_DATA
-XHTXT1 = LV_TEXT.
REPLACE ‘<(>&<)>‘ IN IT_DATA-XHTXT1 WITH ‘&‘.
CLEAR:LT_LINE[], LT_LINE, LV_TEXT.
ENDIF.

*ENDIF.

*&L4.get dinsh: IT_DATA
-DINSH = 0.

*&L5.get umrez1 IT_DATA
-UMREZ1 = IT_DATA-UMREZ.
CONDENSE IT_DATA-UMREZ1 NO-GAPS.

CONCATENATE IT_DATA-UMREZ1 ‘ pc(s)‘ INTO IT_DATA-UMREZ1.

*&L6.get statu:
READ TABLE LT_ZSTATU WITH KEY ZMDNM = IT_DATA-ZMDNM BINARY SEARCH.
IF SY-SUBRC EQ 0. IT_DATA
-STATU = ‘New‘.
ENDIF.
*&L7.get us$
READ TABLE LT_A005 WITH KEY MATNR = IT_DATA-MATNR BINARY SEARCH.
IF SY-SUBRC EQ 0. IT_DATA
-KONWA = LT_A005-KONWA.
*& Convert units
CALL FUNCTION ‘CONVERSION_EXIT_CUNIT_OUTPUT‘
EXPORTING
INPUT = LT_A005-KMEIN
LANGUAGE = ‘1‘
IMPORTING
* LONG_TEXT =
OUTPUT = LT_A005-KMEIN
* SHORT_TEXT =
EXCEPTIONS UNIT_NOT_FOUND
= 1
OTHERS = 2.
IF LT_A005-KMEIN EQ ‘PC‘. IT_DATA
-KBETR = LT_A005-KBETR.
ELSE. IT_DATA
-KBETR = LT_A005-KBETR / IT_DATA-UMREZ."转换单位
ENDIF.
ENDIF.

*&L8.get labst
READ TABLE LT_MARD3 WITH KEY MATNR = IT_DATA-MATNR BINARY SEARCH.
IF SY-SUBRC EQ 0. IT_DATA
-KCNGE = LT_MARD3-LABST.
ENDIF.

READ TABLE LT_ZSD131 WITH KEY MATNR = IT_DATA-MATNR BINARY SEARCH.
IF SY-SUBRC EQ 0. IT_DATA
-KCNGE = IT_DATA-KCNGE - LT_ZSD131-WJENG.
ENDIF.

*&L9.get last3 order qty:--->这里的是以CAR 为单位的数量
READ TABLE LT_VBAK1 WITH KEY MATNR = IT_DATA-MATNR INDEX = 3.
IF SY-SUBRC EQ 0. IT_DATA
-LAST3 = LT_VBAK1-KWMENG * IT_DATA-UMREZ.

ENDIF.

*&L10 get last2 order qty:
READ TABLE LT_VBAK1 WITH KEY MATNR = IT_DATA-MATNR INDEX = 2.
IF SY-SUBRC EQ 0. IT_DATA
-LAST2 = LT_VBAK1-KWMENG * IT_DATA-UMREZ.
ENDIF.

*&L11 get last1 order qty:
READ TABLE LT_VBAK1 WITH KEY MATNR = IT_DATA-MATNR INDEX = 1.
IF SY-SUBRC EQ 0. IT_DATA
-LAST1 = LT_VBAK1-KWMENG * IT_DATA-UMREZ.
ENDIF.

IF RB_PDF EQ ‘X‘. L_KBETR
= IT_DATA-KBETR. L_KONWA
= IT_DATA-KONWA.
MOVE-CORRESPONDING IT_DATA TO IT_DATAP.
CONCATENATE L_KBETR L_KONWA INTO IT_DATAP-KBETR SEPARATED BY SPACE.
COLLECT IT_DATAP.
DELETE IT_DATAP WHERE ZONGL IS INITIAL.
ELSE.
MOVE-CORRESPONDING IT_DATA TO IT_DATAC.
COLLECT IT_DATAC.
DELETE IT_DATAC WHERE ZONGL IS INITIAL.
ENDIF.

MODIFY IT_DATA." INDEX SY-TABIX.
ENDLOOP.

* DESCRIBE TABLE LT_data LINES L_LEN.

ENDFORM. " frm_get_data

*&---------------------------------------------------------------------*
*& Form frm_alv_output
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_ALV_OUTPUT .
DATA: L_NN TYPE I.
DATA: LS_EVENT TYPE SLIS_ALV_EVENT.

*&===>fieldcat
DEFINE ADD_FIELDCAT.
CLEAR WA_FIELDCAT. WA_FIELDCAT
-FIELDNAME = &1. WA_FIELDCAT
-SELTEXT_L = &2. WA_FIELDCAT
-KEY = &3. WA_FIELDCAT
-COL_POS = L_NN + 1. WA_FIELDCAT
-JUST = &4. WA_FIELDCAT
-OUTPUTLEN = &5. WA_FIELDCAT
-FIX_COLUMN = &6. WA_FIELDCAT
-NO_ZERO = &7. WA_FIELDCAT
-EDIT = &8.
APPEND WA_FIELDCAT TO GT_FIELDCAT.
END-OF-DEFINITION.

CLEAR GT_FIELDCAT.
REFRESH GT_FIELDCAT. ADD_FIELDCAT

‘MATNR‘ ‘Material number‘ ‘‘ ‘‘ ‘18‘ ‘‘ ‘‘ ‘‘."1 ADD_FIELDCAT
‘STATU‘ ‘Status‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘."1 ADD_FIELDCAT

‘ZONGL‘ ‘Main Category‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘."2 ADD_FIELDCAT
‘FENEL‘ ‘Sub Category‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘."3 ADD_FIELDCAT
‘ZMDNM‘ ‘Model name‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘."5 ADD_FIELDCAT
‘UMREZ‘ ‘PC per MC‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘."4 ADD_FIELDCAT

‘XHTXT‘ ‘Item text‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘."5 ADD_FIELDCAT
‘XHTXT1‘ ‘Prod Subhead‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘."5

* ADD_FIELDCAT ‘KBETR‘ ‘US$‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘."7

ADD_FIELDCAT
‘KBETR‘ ‘Price‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘."7 ADD_FIELDCAT
‘KONWA‘ ‘Currency‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘."7 ADD_FIELDCAT
‘KCNGE‘ ‘Current Availabile‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘."7 ADD_FIELDCAT

‘DINSH‘ ‘Ordered Qty‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘."8 ADD_FIELDCAT
‘LAST1‘ ‘Last-1 Ordered Qty‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘."9 ADD_FIELDCAT
‘LAST2‘ ‘Last-2 Ordered Qty‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘."10 ADD_FIELDCAT
‘LAST3‘ ‘Last-3 Ordered Qty‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘."11

*&===>layout GW_LAYOUT
-COLWIDTH_OPTIMIZE = ‘X‘. GW_LAYOUT
-ZEBRA = ‘X‘. GW_LAYOUT
-DETAIL_POPUP = ‘X‘.

*&===>Way1:
*&use event to get frm_top_of_page.
*&===>event
CALL FUNCTION ‘REUSE_ALV_EVENTS_GET‘
EXPORTING I_LIST_TYPE
= 0
IMPORTING ET_EVENTS
= GT_EVENT
EXCEPTIONS LIST_TYPE_WRONG
= 1
OTHERS = 2.
READ TABLE GT_EVENT WITH KEY NAME = SLIS_EV_TOP_OF_PAGE INTO LS_EVENT.
IF SY-SUBRC EQ 0.
MOVE ER_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
APPEND LS_EVENT TO GT_EVENT.
ENDIF.

*&TOP OF PAGE.
PERFORM COMMENT_BUILD USING TOP_OF_PAGE[].

*& 调用函数显示ALV列表
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY‘
EXPORTING I_CALLBACK_PROGRAM
= SY-REPID I_SAVE
= ‘A‘ IS_LAYOUT
= GW_LAYOUT IT_FIELDCAT
= GT_FIELDCAT IT_EVENTS
= GT_EVENT
TABLES T_OUTTAB
= IT_DATA
EXCEPTIONS PROGRAM_ERROR
= 1
OTHERS = 2.

ENDFORM. " frm_alv_output

*&---------------------------------------------------------------------*
*& Form comment_build
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->U_ER_LIST_TOP_OF_PAGE text
*----------------------------------------------------------------------*
FORM COMMENT_BUILD USING U_ER_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.

DATA: LS_LINE TYPE SLIS_LISTHEADER, LV_CUST
TYPE STRING, LV_STR
TYPE STRING.

CLEAR: LS_LINE, LV_STR. LS_LINE
-TYP = ‘H‘.

SELECT SINGLE NAME1
INTO LV_CUST
FROM KNA1
WHERE KUNNR EQ P_KUNNR.

CONCATENATE LV_CUST ‘Sold-to Price list‘ INTO LV_STR. LS_LINE
-INFO = LV_STR.
APPEND LS_LINE TO U_ER_LIST_TOP_OF_PAGE.

CLEAR: LS_LINE, LV_STR. LS_LINE
-TYP = ‘S‘.
CONCATENATE ‘Valid as:‘ P_ERDAT+0(4) ‘-‘ P_ERDAT+4(2) ‘-‘ P_ERDAT+6(2) INTO LV_STR.

LS_LINE
-KEY = LV_STR.
APPEND LS_LINE TO U_ER_LIST_TOP_OF_PAGE.

ENDFORM. " COMMENT_BUILDS

*---------------------------------------------------------------------*
* FORM top_of_page *
*---------------------------------------------------------------------*
FORM TOP_OF_PAGE.

CALL FUNCTION ‘REUSE_ALV_COMMENTARY_WRITE‘
EXPORTING I_LOGO
= ‘ENJOYSAP_LOGO‘"‘ZMG_LOGO_NEW‘ IT_LIST_COMMENTARY
= TOP_OF_PAGE.

ENDFORM. "TOP_OF_PAGE

*&---------------------------------------------------------------------*
*& Form FRM_PDF_OUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_PDF_OUT.
*& get print data:
*& one brad ,on pdf fiel, use a new logos
DATA:BEGIN OF LT_MATKL OCCURS 0, MATKL
LIKE MARA-MATKL,
END OF LT_MATKL.
DATA: LT_DATAP LIKE TABLE OF IT_DATAP WITH HEADER LINE.
*& smartform print:
DATA: FM_NAME TYPE RS38L_FNAM,"smartforms 函数 W_CTRLOP
TYPE SSFCTRLOP, "Smart Forms: 控制结构 "W_CONTROL W_COMPOP
TYPE SSFCOMPOP, "SAP Smart Forms: 智能写作器 (传输) 选项"W_OUTPUT. W_RETURN
TYPE SSFCRESCL. "Smart Forms: 表格打印结束时返回值
DATA: H_FILE TYPE STRING, "保存文件的名字 P_PATH
TYPE STRING. "保存路径
DATA: P_MATKL LIKE MARA-MATKL.
DATA: JOB_OUTPUT_INFO TYPE SSFCRESCL, JOB_OUTPUT_OPTIONS
TYPE SSFCRESOP, GT_TABLE
LIKE STANDARD TABLE OF SPFLI.
*&pdf打印需要用到的参数
DATA L_LINES TYPE TABLE OF TLINE WITH HEADER LINE.
DATA L_DOCS TYPE TABLE OF DOCS.
DATA LEN TYPE I.
DATA: G_PDF_XSTRING TYPE XSTRING.

LOOP AT IT_DATAP. IT_DATAP
-KUNNR = P_KUNNR.
SELECT SINGLE VALUE
INTO IT_DATAP-KCSHU
FROM ZT0002
WHERE FROMB LE IT_DATAP-KCNGE
AND FROME GE IT_DATAP-KCNGE. LT_MATKL

-MATKL = IT_DATAP-MATKL.
COLLECT LT_MATKL.
MODIFY IT_DATAP TRANSPORTING KUNNR. "MATKL.
ENDLOOP.
SORT IT_DATAP BY MATKL. LT_DATAP[]

= IT_DATAP[].

REFRESH IT_DATAP[]. W_CTRLOP

-GETOTF = ‘X‘."OTF 表的返回 W_CTRLOP
-NO_DIALOG = ‘X‘."关闭打印对话框 W_CTRLOP
-LANGU = SY-LANGU. W_COMPOP
-TDDEST = ‘LP01‘. "LP01 W_COMPOP
-TDPRINTER = ‘CNSAPWIN‘. "LP01 W_COMPOP
-TDIMMED = ‘X‘. W_COMPOP
-TDDELETE = ‘ ‘. W_COMPOP
-TDTITLE = SY-TITLE.

*&deal with brand 1 by 1.
LOOP AT LT_MATKL.
* READ TABLE LT_MATKL INDEX 1. IT_DATAP[]
= LT_DATAP[]. P_MATKL
= LT_MATKL-MATKL.
DELETE IT_DATAP[] WHERE MATKL NE LT_MATKL-MATKL.

*&smartforms 函数名字转换
CALL FUNCTION ‘SSF_FUNCTION_MODULE_NAME‘
EXPORTING FORMNAME
= ‘ZOK_CUSTOMER6‘
IMPORTING FM_NAME
= FM_NAME.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

*&smartforms打印 ,将打印的值输入到W_RETURN-OTFDATA[]中
CALL FUNCTION FM_NAME
EXPORTING CONTROL_PARAMETERS
= W_CTRLOP OUTPUT_OPTIONS
= W_COMPOP USER_SETTINGS
= ‘X‘" USER_SETTINGS = ‘X‘
IMPORTING JOB_OUTPUT_INFO
= W_RETURN.

* CALL FUNCTION FM_NAME
* EXPORTING
* CONTROL_PARAMETERS = W_CTRLOP
* IMPORTING
* JOB_OUTPUT_INFO = W_RETURN
* JOB_OUTPUT_OPTIONS = JOB_OUTPUT_OPTIONS
* TABLES
* IT_TABLE = GT_TABLE
* EXCEPTIONS
* FORMATTING_ERROR = 1
* INTERNAL_ERROR = 2
* SEND_ERROR = 3
* USER_CANCELED = 4
* OTHERS = 5.

*&W3.call fc ‘convert_otf‘ to get g_pdf_xstring up files.
CALL FUNCTION ‘CONVERT_OTF‘
EXPORTING
FORMAT = ‘PDF‘
* MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ‘ ‘
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ‘ ‘
* PDF_DELETE_OTFTAB = ‘ ‘
* PDF_USERNAME = ‘ ‘
* PDF_PREVIEW = ‘ ‘
* USE_CASCADING = ‘ ‘
IMPORTING BIN_FILESIZE
= LEN BIN_FILE
= G_PDF_XSTRING
TABLES OTF
= W_RETURN-OTFDATA[]
LINES = L_LINES[]
EXCEPTIONS ERR_MAX_LINEWIDTH
= 1 ERR_FORMAT
= 2 ERR_CONV_NOT_POSSIBLE
= 3 ERR_BAD_OTF
= 4
OTHERS = 5.

IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* INTO G_DUMMY
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* PERFORM protocol_update.
* RETURN.
ENDIF.
CONCATENATE P_SEFILE P_KUNNR P_MATKL ‘_Price list.pdf‘ INTO S_FILE. "addrss
OPEN DATASET S_FILE FOR OUTPUT IN BINARY MODE." MESSAGE L_MESSAGE_DB.
IF SY-SUBRC EQ 0.
TRANSFER G_PDF_XSTRING TO S_FILE.
CLOSE DATASET S_FILE.
ELSE.
MESSAGE ‘OPEN ERROR!!‘ TYPE ‘E‘.
STOP.
ENDIF.

ENDLOOP.

ENDFORM. " FRM_PDF_OUT

*&---------------------------------------------------------------------*
*& Form FRM_CSV_OUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_CSV_OUT .
DATA:UMREZ(20), DINSH
(20), LAST1
(20), LAST2
(20), LAST3
(20).

LOOP AT IT_DATAC.
CONCATENATE ‘"‘ IT_DATAC-ZONGL ‘"‘ INTO IT_DATAC-ZONGL.
CONCATENATE ‘"‘ IT_DATAC-FENEL ‘"‘ INTO IT_DATAC-FENEL.

SELECT SINGLE VALUE
INTO IT_DATAC-KCSHU
FROM ZT0002
WHERE FROMB LE IT_DATAC-KCNGE
AND FROME GE IT_DATAC-KCNGE.
MODIFY IT_DATAC TRANSPORTING ZONGL FENEL KCSHU.
ENDLOOP.

SORT IT_DATAC BY ZONGL FENEL ZMDNM.

CONCATENATE P_SEFILE P_KUNNR ‘_Order Form.csv‘ INTO S_FILE. "服务器保存的目录和文

件名
OPEN DATASET S_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT . "打开文件
IF SY-SUBRC = 0.

CONCATENATE ‘Status‘ ‘Main Category‘ ‘Sub Category‘ ‘Model Name‘ ‘PC per MC‘

‘Current Available‘ ‘Ordered Qty‘ ‘Last-1‘ ‘Last-2‘ ‘Last-3‘
INTO LINE SEPARATED BY ‘,‘.
TRANSFER LINE TO S_FILE .

LOOP AT IT_DATAC. DINSH
= IT_DATAC-DINSH. LAST1
= IT_DATAC-LAST1. LAST2
= IT_DATAC-LAST2. LAST3
= IT_DATAC-LAST3.

CONCATENATE IT_DATAC-STATU IT_DATAC
-ZONGL IT_DATAC
-FENEL IT_DATAC
-ZMDNM IT_DATAC
-UMREZ1 IT_DATAC
-KCSHU DINSH LAST1 LAST2

LAST3

INTO LINE SEPARATED BY ‘,‘.

TRANSFER LINE TO S_FILE .
IF SY-SUBRC NE 0 .
MESSAGE ‘ERROR!!‘ TYPE ‘E‘.
STOP.
ENDIF.
CLEAR LINE .
ENDLOOP.
CLOSE DATASET S_FILE.
ELSE.
MESSAGE ‘OPEN ERROR!!‘ TYPE ‘E‘.
STOP.
ENDIF.

ENDFORM. " FRM_CSV_OUT

时间: 2024-11-24 08:48:36

ZSDR017-客户订货价格和库存的相关文章

新手如何与客户谈价格

做外贸的朋友都知道,价格是谁都绕不开的因素,跟供应商需要谈价格,跟客人需要谈价格,跟货代船公司快递公司同样需要谈价格.总之,价格是外贸环节中无法回避的一个因素,尤其是跟客人之间的价格谈判,因为双方文化背景的差异.信息的不对称,以及如今买卖双方地位的严重倾斜,使得很多新手最怕跟客人谈论价格问题,生怕“见光死”,同时面对客人的砍价变得无所适从,最终不是把订单做亏或者维持极低极低的利润,就是失去订单甚至失去客人的信任,并最终失去这个客人.     尤其是对于新接触或初次询价的客人,因为双方并没有实质性

Java门店管理系统 客户资料档案管理 库存管理 进销存 SSM项目源码

系统介绍: 1.系统采用主流的 SSM 框架 jsp JSTL bootstrap html5 (PC浏览器使用) 2.springmvc +spring4.3.7+ mybaits3.3  SSM 普通java web(非maven, 附赠pom.xml文件)  数据库:mysql 3.开发工具:myeclipse  eclipse idea 均可, 没有限制. 我这边myeclipse 2014 导出来的项目源码 ---------------------------------------

Java 门店管理系统 客户信息 档案管理 库存管理 进销存 SSM 项目源码

统介绍: 1.系统采用主流的 SSM 框架 jsp JSTL bootstrap html5 (PC浏览器使用) 2.springmvc +spring4.3.7+ mybaits3.3  SSM 普通java web(非maven, 附赠pom.xml文件)  数据库:mysql 3.开发工具:myeclipse  eclipse idea 均可, 没有限制. 我这边myeclipse 2014 导出来的项目源码 ----------------------------------------

谭八爷代理订货平台系统

谭八爷代理订货平台系统  135.3879.3268   谭八爷微商下单系统.谭八爷微商管理系统.谭八爷代理商下单系统等.模式系统开发 传统行业和内容提供本质没有变,但是在结合互联网后的商业模式和运营模式变了,如当前我们谈的多的O2O,核心不是内容提供变化了,是商业模式变化了,这个商业模式变化本身又依托了一个重要假设,即解决了传统行业原有的信息不对称问题. 谭八爷微商平台系统开发的注册流程是非常简单的--扫码注册.同时后台的功能也很强大,代理们收到顾客订单后可以直接在后台向公司下单,同时后台也会

拼多多、云集、爱库存,社交电商的三驾马车有啥不同?

爱库存AAXP9M01第一家纯粹的社交电商拼多多上市已经有一段时间了,喊了多年的社交电商,终于迎来了第一股!这是有标志性意义的.能够从众多社交电商中杀出来,第一个冲到公开资本市场,拼多多实数不易,而在拼多多之后,还有多家社交电商,发展形势很好,比如云集.爱库存等,他们谁能成为拼多多之后第二个上市的社交电商呢?社交电商的发展,未来又会怎么样?02都说社交电商是未来的趋势,但社交电商跟其他电商究竟有什么不一样的呢?我们想想看,淘宝有5亿多用户,但微信有10亿多用户,剩下那五个亿去哪儿了?他们为什么不

大型时装企业如何应用RPA处理客户订单?

日本大型时装企业--株式会社青木(株式会社AOKI),成立于2008年4月1日,是株式会社青木控股(株式会社AOKI Holdings)的全资子公司,被东京奥组委指定为2020年东京奥运会官方商务正装供应商.AOKI旗下不仅有网上商城,实体门店也遍布日本各地.其中,AOKI门店574家.ORIHICA门店137家.随着新零售时代的来临,线上线下融合加快,每天靠人工手动处理大量订单,不仅耗时费力,而且还容易出错.于是,AOKI决定在EC运营(电商运营)中导入RPA,使客户订单处理自动化. RPA导

当客户说“贵”时,你该怎么办?

▌在销售过中,我们往往会遇到以下的几种情境: 1.你们的产品价格太贵了: 2.今天不买,过些天再买: 3.我再转转,看看再说: 4.别讲太多了,你多少钱能卖吧: 5.今天不买,等你们做活动的时候再买: 6.价格已经到底限了,但客户还在拼命杀价: 遇到这些情况,我们又应该怎样去应对呢?   一.销售情境1:你的价格太贵了 错误应对: 1 .价格好商量 ……2 .对不起 , 我们是品牌 , 不还价 ▌问题诊断: 客户买东西时都会想要便宜点,这是客户的一个正常的消费心理,并不是决定他买不买的主要问题.

Odoo 的库存管理与OpenERP之前的版本有了很大的不同,解读Odoo新的WMS模块中的新特性

原文来自:http://shine-it.net/index.php/topic,16409.0.html 库存移动(Stock Move)新玩法Odoo的库存移动不仅仅是存货在两个“存货地点”之间的移动的基本概念了,他们可以被“串联”在一起,可以用来生成或改变其对应的拣货单(Picking).链式库存移动被广泛应用在各类库存操作中比如:多步收货或多步发货操作,多仓库间的配.补货操作等:而不仅限于之前OpenERP中MTO供货类型产品的发货等待对应供应商收货这样的链式库存移动的应用场景了.我们会

关于成本核算方法、步骤、成本分析的简单回复

关于成本核算方法.步骤.成本分析的简单回复成本核算的方法依据企业生产产品的特点来定:主要看产品是否是多步骤生产(生产工艺的特点):半成品是否有销售的情况(假设有销售,可能须要採用分步核算,以便准确核算半成品的成本):工作(成本/生产)中心是依照产品来分还是工艺来分.怎样核算成本:首先归集产品的材料成本,一般都须要技术部门提供产品的BOM(物料清单),以确保按订单或者生产计划生产的时候领料的准确.(通常会问生产线出现来料不良和损坏怎么处理:退仓并补领就可以,损坏部分须要当月预提计入制费,损坏材料报