ENHANCEMENT 1 ZVF01_DATA_DOWNLOAD_RFC. "active version
*REQ NO: DEVK904147 DATE: 21.06.2013
*
TYPE-POOLS: TRUXS.
TYPE-POOLS: TRUXS.
* DATA: P_FILE LIKE SAPB-SAPPFAD.
DATA: L_STRING TYPE STRING.
DATA : CON_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
DATA : HEX(1) TYPE C VALUE ';', "Tab Space
V_CON TYPE STRING," TRUXS_T_TEXT_DATA," type c occurs 0.,
SEP(2) TYPE C VALUE ';'.
DATA: IT_TEMP TYPE TRUXS_T_TEXT_DATA.
TYPES: BEGIN OF ty_vbrp,
vbeln TYPE vbrp-vbeln,
posnr TYPE VBRP-POSNR,
matnr TYPE VBRP-MATNR,
arktx TYPE VBRP-ARKTX,
fkimg TYPE VBRP-FKIMG,
vgbel TYPE vBRP-VGBEL,
END OF ty_vbrp.
TYPES: BEGIN OF TY,
VBELN TYPE VBRK-VBELN,
FKART TYPE VBRK-FKART,
POSNR TYPE VBRP-POSNR,
MATNR TYPE VBRP-MATNR,
ARKTX TYPE VBRP-ARKTX,
FKIMG(17)," TYPE VBRP-FKIMG,
VGBEL TYPE VBRP-VGBEL,
zdate(10),
ztime(8),
KUNAG TYPE VBRK-KUNAG,
zdate1(10),
ztime1(8),
ERNAM TYPE VBRK-ERNAM,
END OF TY.
TYPES: BEGIN OF ITAB,
F1(25),
END OF ITAB.
DATA: IT TYPE TABLE OF TY,
WA LIKE LINE OF IT,
it_vbrp TYPE TABLE OF ty_vbrp,
WA_VBRK like xVBRK,
WA_VBRP like LINE OF it_VBRP,
ITAB1 TYPE TABLE OF ITAB,
W1 LIKE LINE OF ITAB1.
DATA: P_FILE TYPE SAPB-SAPPFAD."RLGRAP-FILENAME.
DATA: STR(30),
fol(15),
clnt(15),
STRING1(15),
STRING2(5),
FILE_NAME TYPE STRING.
DATA: V_DATE(10) TYPE C,
V_DATE1(10) TYPE C,
V_DATE2(10) TYPE C,
V_DATE3(8) TYPE C,
V_DATE4(8) TYPE C,
ZYY(4) TYPE C,
ZMM(2) TYPE C,
ZDD(2) TYPE C,
ZYY1(4) TYPE C,
ZMM1(2) TYPE C,
ZDD1(2) TYPE C,
ZYY3(2) TYPE C,
ZMM3(2) TYPE C,
ZDD3(2) TYPE C,
ZYY4(2) TYPE C,
ZMM4(2) TYPE C,
ZDD4(2) TYPE C,
ZDATE(10) TYPE C,
ZDATE1(10) TYPE C,
ZTIME(8) TYPE C,
ZTIME1(8) TYPE C.
if sy-tcode eq 'VF01'." or sy-tcode eq 'VF02'.
STRING1 = xVBRK-VBELN.
V_DATE = xVBRK-FKDAT.
V_DATE1 = xVBRK-ERDAT.
V_DATE3 = xVBRK-ERZET.
V_DATE4 = xVBRK-ERZET.
if xvbrk-mandt eq '200'.
clnt = '/DEV:/'.
ELSEIF XVBRK-MANDT EQ '110'.
clnt = '/qas/'.
ELSEIF XVBRK-MANDT EQ '100'.
clnt = '/pas/'.
ENDIF.
FOL = 'Billing/'.
STRING2 = '.txt'.
TRANSLATE STRING2 TO LOWER CASE.
CONCATENATE clnt fol string1 string2 into p_file." file_name.
ZYY = V_DATE+0(4).
ZMM = V_DATE+4(2).
ZDD = V_DATE+6(2).
ZYY1 = V_DATE1+0(4).
ZMM1 = V_DATE1+4(2).
ZDD1 = V_DATE1+6(2).
ZYY3 = V_DATE3+0(2).
ZMM3 = V_DATE3+2(2).
ZDD3 = V_DATE3+4(2).
ZYY3 = V_DATE4+0(2).
ZMM3 = V_DATE4+2(2).
ZDD3 = V_DATE4+4(2).
CONCATENATE ZDD '.' ZMM '.' ZYY INTO ZDATE.
CONCATENATE ZDD1 '.' ZMM1 '.' ZYY1 INTO ZDATE1.
CONCATENATE ZYY3 ':' ZMM3 ':' ZDD3 INTO ZTIME.
CONCATENATE ZYY4 ':' ZMM4 ':' ZDD4 INTO ZTIME1.
select vbeln POSNR MATNR ARKTX FKIMG VGBEL
from vbrp
INTO CORRESPONDING FIELDS OF TABLE it_vbrp
WHERE vbeln = xvbrk-vbeln.
OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
CONCATENATE 'Biilig No' 'Bill Type' 'Item No' 'Material Code' 'Materail Desc' 'Bill Qty' 'Ref Doc(DeliveryNo)' 'Billing Date' 'Billing Time' 'Sold To Party' 'Entry Date' 'Entry Time' 'Entered By'
INTO V_CON SEPARATED BY CON_TAB.
TRANSFER V_CON TO P_FILE.
LOOP AT it_VBRP INTO WA_VBRP.
WA-VBELN = wa_VBRP-VBELN.
WA-POSNR = wa_VBRP-POSNR.
WA-MATNR = wa_VBRP-MATNR.
WA-ARKTX = wa_VBRP-ARKTX.
WA-FKIMG = wa_VBRP-FKIMG.
WA-VGBEL = wa_VBRP-VGBEL.
WA-FKART = xVBRK-FKART.
WA-zdate = ZDATE.
WA-ztime = ZTIME.
WA-KUNAG = xVBRK-KUNAG.
WA-zdate1 = ZDATE1.
WA-ztime1 = ZTIME.
WA-ERNAM = xVBRK-ERNAM.
CONCATENATE WA-VBELN WA-POSNR WA-MATNR WA-ARKTX WA-FKIMG WA-VGBEL WA-FKART
WA-zdate WA-ztime WA-KUNAG WA-zdate1 WA-ztime1 WA-ERNAM
INTO V_CON SEPARATED BY CON_TAB.
TRANSFER V_CON TO P_FILE.
CLEAR: WA, WA_VBRP, WA_VBRK.
ENDLOOP.
CLOSE DATASET P_FILE.
ENDIF.
ENDENHANCEMENT.
*$*$-End: (1)---------------------------------------------------------------------------------$*$*
ENDFUNCTION.
*REQ NO: DEVK904147 DATE: 21.06.2013
*
TYPE-POOLS: TRUXS.
TYPE-POOLS: TRUXS.
* DATA: P_FILE LIKE SAPB-SAPPFAD.
DATA: L_STRING TYPE STRING.
DATA : CON_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
DATA : HEX(1) TYPE C VALUE ';', "Tab Space
V_CON TYPE STRING," TRUXS_T_TEXT_DATA," type c occurs 0.,
SEP(2) TYPE C VALUE ';'.
DATA: IT_TEMP TYPE TRUXS_T_TEXT_DATA.
TYPES: BEGIN OF ty_vbrp,
vbeln TYPE vbrp-vbeln,
posnr TYPE VBRP-POSNR,
matnr TYPE VBRP-MATNR,
arktx TYPE VBRP-ARKTX,
fkimg TYPE VBRP-FKIMG,
vgbel TYPE vBRP-VGBEL,
END OF ty_vbrp.
TYPES: BEGIN OF TY,
VBELN TYPE VBRK-VBELN,
FKART TYPE VBRK-FKART,
POSNR TYPE VBRP-POSNR,
MATNR TYPE VBRP-MATNR,
ARKTX TYPE VBRP-ARKTX,
FKIMG(17)," TYPE VBRP-FKIMG,
VGBEL TYPE VBRP-VGBEL,
zdate(10),
ztime(8),
KUNAG TYPE VBRK-KUNAG,
zdate1(10),
ztime1(8),
ERNAM TYPE VBRK-ERNAM,
END OF TY.
TYPES: BEGIN OF ITAB,
F1(25),
END OF ITAB.
DATA: IT TYPE TABLE OF TY,
WA LIKE LINE OF IT,
it_vbrp TYPE TABLE OF ty_vbrp,
WA_VBRK like xVBRK,
WA_VBRP like LINE OF it_VBRP,
ITAB1 TYPE TABLE OF ITAB,
W1 LIKE LINE OF ITAB1.
DATA: P_FILE TYPE SAPB-SAPPFAD."RLGRAP-FILENAME.
DATA: STR(30),
fol(15),
clnt(15),
STRING1(15),
STRING2(5),
FILE_NAME TYPE STRING.
DATA: V_DATE(10) TYPE C,
V_DATE1(10) TYPE C,
V_DATE2(10) TYPE C,
V_DATE3(8) TYPE C,
V_DATE4(8) TYPE C,
ZYY(4) TYPE C,
ZMM(2) TYPE C,
ZDD(2) TYPE C,
ZYY1(4) TYPE C,
ZMM1(2) TYPE C,
ZDD1(2) TYPE C,
ZYY3(2) TYPE C,
ZMM3(2) TYPE C,
ZDD3(2) TYPE C,
ZYY4(2) TYPE C,
ZMM4(2) TYPE C,
ZDD4(2) TYPE C,
ZDATE(10) TYPE C,
ZDATE1(10) TYPE C,
ZTIME(8) TYPE C,
ZTIME1(8) TYPE C.
if sy-tcode eq 'VF01'." or sy-tcode eq 'VF02'.
STRING1 = xVBRK-VBELN.
V_DATE = xVBRK-FKDAT.
V_DATE1 = xVBRK-ERDAT.
V_DATE3 = xVBRK-ERZET.
V_DATE4 = xVBRK-ERZET.
if xvbrk-mandt eq '200'.
clnt = '/DEV:/'.
ELSEIF XVBRK-MANDT EQ '110'.
clnt = '/qas/'.
ELSEIF XVBRK-MANDT EQ '100'.
clnt = '/pas/'.
ENDIF.
FOL = 'Billing/'.
STRING2 = '.txt'.
TRANSLATE STRING2 TO LOWER CASE.
CONCATENATE clnt fol string1 string2 into p_file." file_name.
ZYY = V_DATE+0(4).
ZMM = V_DATE+4(2).
ZDD = V_DATE+6(2).
ZYY1 = V_DATE1+0(4).
ZMM1 = V_DATE1+4(2).
ZDD1 = V_DATE1+6(2).
ZYY3 = V_DATE3+0(2).
ZMM3 = V_DATE3+2(2).
ZDD3 = V_DATE3+4(2).
ZYY3 = V_DATE4+0(2).
ZMM3 = V_DATE4+2(2).
ZDD3 = V_DATE4+4(2).
CONCATENATE ZDD '.' ZMM '.' ZYY INTO ZDATE.
CONCATENATE ZDD1 '.' ZMM1 '.' ZYY1 INTO ZDATE1.
CONCATENATE ZYY3 ':' ZMM3 ':' ZDD3 INTO ZTIME.
CONCATENATE ZYY4 ':' ZMM4 ':' ZDD4 INTO ZTIME1.
select vbeln POSNR MATNR ARKTX FKIMG VGBEL
from vbrp
INTO CORRESPONDING FIELDS OF TABLE it_vbrp
WHERE vbeln = xvbrk-vbeln.
OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
CONCATENATE 'Biilig No' 'Bill Type' 'Item No' 'Material Code' 'Materail Desc' 'Bill Qty' 'Ref Doc(DeliveryNo)' 'Billing Date' 'Billing Time' 'Sold To Party' 'Entry Date' 'Entry Time' 'Entered By'
INTO V_CON SEPARATED BY CON_TAB.
TRANSFER V_CON TO P_FILE.
LOOP AT it_VBRP INTO WA_VBRP.
WA-VBELN = wa_VBRP-VBELN.
WA-POSNR = wa_VBRP-POSNR.
WA-MATNR = wa_VBRP-MATNR.
WA-ARKTX = wa_VBRP-ARKTX.
WA-FKIMG = wa_VBRP-FKIMG.
WA-VGBEL = wa_VBRP-VGBEL.
WA-FKART = xVBRK-FKART.
WA-zdate = ZDATE.
WA-ztime = ZTIME.
WA-KUNAG = xVBRK-KUNAG.
WA-zdate1 = ZDATE1.
WA-ztime1 = ZTIME.
WA-ERNAM = xVBRK-ERNAM.
CONCATENATE WA-VBELN WA-POSNR WA-MATNR WA-ARKTX WA-FKIMG WA-VGBEL WA-FKART
WA-zdate WA-ztime WA-KUNAG WA-zdate1 WA-ztime1 WA-ERNAM
INTO V_CON SEPARATED BY CON_TAB.
TRANSFER V_CON TO P_FILE.
CLEAR: WA, WA_VBRP, WA_VBRK.
ENDLOOP.
CLOSE DATASET P_FILE.
ENDIF.
ENDENHANCEMENT.
*$*$-End: (1)---------------------------------------------------------------------------------$*$*
ENDFUNCTION.
No comments:
Post a Comment