WMS函数组:5.取销售价格
FUNCTION ZRFC_ESB088.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" VALUE(IT) LIKE ZRFC_ESB088_INPUT STRUCTURE ZRFC_ESB088_INPUT
*" EXPORTING
*" VALUE(EP_SUBRC) LIKE SY-SUBRC
*" VALUE(TAX_RATE) TYPE KBETR
*" TABLES
*" ITAB STRUCTURE KONP OPTIONAL
*"----------------------------------------------------------------------
INCLUDE ZRFC_CNT.
DATA: ITH LIKE T682I OCCURS 0 WITH HEADER LINE.
DATA: V_KOZGF TYPE KOZGF.
DATA BEGIN OF TABLE_STRUCTURE OCCURS 10.
INCLUDE STRUCTURE DFIES.
DATA END OF TABLE_STRUCTURE.
DATA TABLE_TYPE TYPE DD02V-TABCLASS.
DATA: BEGIN OF WHKS OCCURS 0,
TEXT(200),
END OF WHKS.
DATA: QUERY_TABLE LIKE DD02L-TABNAME.
QUERY_TABLE = 'ZRFC_ESB088_INPUT'.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
TABNAME = QUERY_TABLE
* FIELDNAME = ' '
LANGU = '1'
* LFIELDNAME = ' '
* ALL_TYPES = ' '
* GROUP_NAMES = ' '
IMPORTING
* X030L_WA =
DDOBJTYPE = TABLE_TYPE
* DFIES_WA =
* LINES_DESCR =
TABLES
DFIES_TAB = TABLE_STRUCTURE
* FIXED_VALUES =
EXCEPTIONS
NOT_FOUND = 1
INTERNAL_ERROR = 2
OTHERS = 3.
RANGES : R_TL FOR TABLE_STRUCTURE-FIELDNAME.
R_TL-SIGN = 'I'.
R_TL-OPTION = 'EQ'.
LOOP AT TABLE_STRUCTURE.
R_TL-LOW = TABLE_STRUCTURE-FIELDNAME.
APPEND R_TL.
ENDLOOP.
CLEAR TABLE_STRUCTURE[].
FIELD-SYMBOLS: <DYN_FIELD> TYPE ANY.
EP_SUBRC = -1.
SELECT SINGLE KOZGF INTO V_KOZGF FROM T685 WHERE KSCHL = IT-KSCHL.
SELECT
*
INTO CORRESPONDING FIELDS OF TABLE ITH FROM T682I
WHERE KVEWE = 'A' AND KAPPL = 'V' AND KOZGF = V_KOZGF.
DATA: IT_KONP LIKE KONP OCCURS 0 WITH HEADER LINE.
DATA: V_KNUMH TYPE KNUMH.
LOOP AT ITH.
CONCATENATE ITH-KVEWE ITH-KOTABNR INTO QUERY_TABLE.
CLEAR TABLE_STRUCTURE[].
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
TABNAME = QUERY_TABLE
* FIELDNAME = ' '
LANGU = '1'
* LFIELDNAME = ' '
* ALL_TYPES = ' '
* GROUP_NAMES = ' '
IMPORTING
* X030L_WA =
DDOBJTYPE = TABLE_TYPE
* DFIES_WA =
* LINES_DESCR =
TABLES
DFIES_TAB = TABLE_STRUCTURE
* FIXED_VALUES =
EXCEPTIONS
NOT_FOUND = 1
INTERNAL_ERROR = 2
OTHERS = 3.
DATA: V_STRING TYPE STRING.
CLEAR V_KNUMH.
CLEAR WHKS[].
WHKS-TEXT = 'MANDT = ''800'' '.
APPEND WHKS.
LOOP AT TABLE_STRUCTURE.
IF TABLE_STRUCTURE-FIELDNAME IN R_TL.
ASSIGN COMPONENT TABLE_STRUCTURE-FIELDNAME OF STRUCTURE IT TO <DYN_FIELD>.
* WRITE <DYN_FIELD>.
PERFORM F_ADD_ZERO USING <DYN_FIELD>.
CONCATENATE '''' <DYN_FIELD> '''' INTO V_STRING.
CONCATENATE ' AND ' TABLE_STRUCTURE-FIELDNAME ' = ' V_STRING INTO WHKS-TEXT SEPARATED BY SPACE.
APPEND WHKS.
ENDIF.
ENDLOOP.
SELECT KNUMH INTO V_KNUMH FROM (QUERY_TABLE) WHERE (WHKS) AND DATBI >= SY-DATUM .
SELECT * APPENDING TABLE ITAB FROM KONP WHERE KNUMH = V_KNUMH AND KSCHL = IT-KSCHL and LOEVM_KO = ''.
ENDSELECT.
ENDLOOP.
CALL FUNCTION 'ZRFC_GET_MWST'
* EXPORTING
* ALAND = 'CN'
* TAXK1 = '1'
* TAXM1 = '1'
* DATBI = SY-DATUM
* DATAB = SY-DATUM
IMPORTING
KBETR = TAX_RATE.
.
IF ITAB[] IS NOT INITIAL.
EP_SUBRC = 0.
ENDIF.
ENDFUNCTION.