Skip to Content
0
Former Member
Jul 27, 2007 at 10:49 PM

Download .xls file in P server while running pgm in background

26 Views

Hi,

Is it possible to download .xls file to presentation server while executing the program in background.

Also, can anybody help me out to increase the performance of following report.

I have included proper indexes for MSEG but still SQL trace showing the issue with that query. Most intresting thing is...sometime report is giving output within 15-20 seconds but sometime it is taking 15-20 minutes to output the result.

rgds

sudhanshu

[code]

REPORT ZCLF_RPT_MM_INVENTORY_BATCHES LINE-SIZE 1023

NO STANDARD PAGE HEADING.

TABLES:mchb,

mch1,

vbbe,

mara,

marm.

&----


*& SELECTION SCREEN DETAILS

&----


SELECTION-SCREEN:BEGIN OF BLOCK blk1 WITH FRAME TITLE text-006.

PARAMETERS:p_day TYPE i.

SELECTION-SCREEN:END OF BLOCK blk1.

SELECTION-SCREEN:BEGIN OF BLOCK blk3 WITH FRAME TITLE text-003.

PARAMETERS: rd_ftp RADIOBUTTON GROUP rd1,

rd_pc RADIOBUTTON GROUP rd1 default 'X',

p_file like rlgrap-filename

default 'C:\Documents and Settings\All Users\Desktop\Agedinventory.xls',

rd_sap RADIOBUTTON GROUP rd1.

SELECTION-SCREEN:END OF BLOCK blk3.

*&&--FTP Details.

SELECTION-SCREEN BEGIN OF BLOCK ftp WITH FRAME TITLE text-002.

PARAMETERS:

p_user(64) TYPE c OBLIGATORY DEFAULT 'FTPUSER',

p_pwd(64) TYPE c OBLIGATORY DEFAULT 'INTRINSIC',

p_host(64) TYPE c OBLIGATORY DEFAULT '172.16.8.67',

p_dir(80) TYPE c OBLIGATORY DEFAULT 'SALESANALYSIS',

p_filenm(80) TYPE c," OBLIGATORY,

p_dest LIKE rfcdes-rfcdest OBLIGATORY DEFAULT 'SAPFTP',

p_comp TYPE c OBLIGATORY DEFAULT 'N',

p_path LIKE cffile-filename OBLIGATORY LOWER CASE.

SELECTION-SCREEN END OF BLOCK ftp.

DATA:BEGIN OF it_outtab OCCURS 0,

cust(3),

name(30),

sname(35),

kunar1(10),

kunar2(10),

kunar3(10),

kunar4(10),

werks(4),

matnr(18),

maktx(40),

juice(18),

charg(10),

hsdat LIKE mch1-hsdat, "production date

date1 LIKE mch1-vfdat, "customer expity date

date2 LIKE mch1-vfdat, "cliffstar expiry date

days TYPE i, "days left to cust. expiry date

clabs LIKE mchb-clabs,

ccase LIKE mbew-stprs, "cost per case for finished

"goods

cgal LIKE mbew-stprs, "juice cost per gal

budat LIKE mkpf-budat, "last sale date

END OF it_outtab.

DATA:BEGIN OF it_ftp OCCURS 0,

cust(3),

name(30),

sname(35),

kunar1(10),

kunar2(10),

kunar3(10),

kunar4(10),

werks(4),

matnr(18),

maktx(40),

juice(18),

charg(10),

hsdat(10), "like mch1-hsdat, "production date

date1(10), "like mch1-vfdat, "customer expity date

date2(10), "like mch1-vfdat, "cliffstar expiry date

days(4), "days left to cust. expiry date

clabs(13), "like mchb-clabs,

ccase(13), "like mbew-stprs, "cost per case for finished

"goods

cgal(13), "like mbew-stprs, "juice cost per gal

budat(10), "last sale date

END OF it_ftp.

DATA: BEGIN OF it_mchb OCCURS 0,

matnr LIKE mchb-matnr,

werks LIKE mchb-werks,

lgort LIKE mchb-lgort,

charg LIKE mchb-charg,

clabs LIKE mchb-clabs,

END OF it_mchb.

DATA: BEGIN OF it_data OCCURS 0,

matnr LIKE mchb-matnr,

werks LIKE mchb-werks,

lgort LIKE mchb-lgort,

charg LIKE mchb-charg,

clabs LIKE mchb-clabs,

hsdat LIKE mch1-hsdat, "Date of Production of the Batch

vfdat LIKE mch1-vfdat, "Shelf Life Expiration Date

alloc_qty LIKE mchb-clabs, "allocated quantity

left_qty LIKE mchb-clabs, "left-out quantity

date1 LIKE mch1-vfdat, "customer expity date

days TYPE i, "days left to cust. expiry date

cust(30), "laboratory office

lab(3), "lab office

kunar1(10), "sales representative

kunar2(10), "customer representative1

kunar3(10), "customer representative2

kunar4(10), "customer representative3

meins LIKE mara-meins,

ccase LIKE mbew-stprs, "cost per case for fin goods

cgal LIKE mbew-stprs, "juice cost per gal

maktx LIKE makt-maktx, "material description

juice(18), "juice style

sname(35),

mblnr LIKE mseg-mblnr,

mjahr LIKE mseg-mjahr,

  • hsdat LIKE mseg-hsdat,

budat LIKE mkpf-budat,

END OF it_data.

DATA:BEGIN OF it_mara OCCURS 0,

matnr LIKE mara-matnr,

meins LIKE mara-meins,

labor LIKE mara-labor,

mhdrz LIKE mara-mhdrz,

mhdhb LIKE mara-mhdhb,

END OF it_mara.

DATA: BEGIN OF it_mch1 OCCURS 0,

matnr LIKE mchb-matnr,

charg LIKE mchb-charg,

vfdat LIKE mch1-vfdat, "Shelf Life Expiration Date

hsdat LIKE mch1-hsdat, "Date of Production of the Batch

END OF it_mch1.

DATA: it_vbbe like vbbe occurs 0 with header line.

DATA:BEGIN OF it_qty OCCURS 0,

matnr LIKE vbbe-matnr,

werks LIKE vbbe-werks,

omeng LIKE vbbe-omeng,

END OF it_qty.

DATA: BEGIN OF it_t024x OCCURS 0,

labor LIKE t024x-labor,

lbtxt LIKE t024x-lbtxt,

END OF it_t024x.

DATA:BEGIN OF it_bom OCCURS 0,

matnr LIKE mast-matnr,

werks LIKE mast-werks,

  • stlan LIKE mast-stlan,

stlnr LIKE mast-stlnr,

stlal LIKE mast-stlal,

valid_dt LIKE sy-datum,

idnrk LIKE stpo-idnrk,

END OF it_bom.

DATA:BEGIN OF it_stko OCCURS 0,

  • stlty LIKE stko-stlty,

stlnr LIKE stko-stlnr,

  • stlal LIKE stko-stlal,

  • stkoz LIKE stko-stkoz,

datuv LIKE stko-datuv,

END OF it_stko.

DATA:BEGIN OF it_stpo OCCURS 0,

stlnr LIKE stpo-stlnr,

datuv LIKE stpo-datuv,

idnrk LIKE stpo-idnrk,

menge LIKE stpo-menge,

END OF it_stpo.

DATA:BEGIN OF it_mbew OCCURS 0,

matnr LIKE mbew-matnr,

bwkey LIKE mbew-bwkey,

stprs LIKE mbew-stprs,

peinh LIKE mbew-peinh,

END OF it_mbew.

DATA:BEGIN OF it_makt OCCURS 0,

matnr LIKE makt-matnr,

maktx LIKE makt-maktx,

END OF it_makt.

DATA it_data1 LIKE it_data OCCURS 0 WITH HEADER LINE.

DATA:v_matnr LIKE vbbe-matnr, v_werks LIKE vbbe-werks,

v_str type string.

DATA:v_idledt LIKE sy-datum,

v_idx TYPE sy-tabix,

v_idx1 TYPE sy-tabix,

v_qty LIKE vbbe-omeng,

first,

v_neg TYPE i VALUE -1,

v_lang LIKE t024x-spras VALUE 'E',

c_tab TYPE x VALUE '09',

p_alloc TYPE i.

data:begin of it_mseg occurs 0,

mblnr like mseg-mblnr,

mjahr like mseg-mjahr,

  • bwart like mseg-bwart,

matnr like mseg-matnr,

werks like mseg-werks,

lgort like mseg-lgort,

  • hsdat like mseg-hsdat,

end of it_mseg.

data:begin of it_mkpf occurs 0,

MBLNR like mkpf-mblnr,

MJAHR like mkpf-mjahr,

BUDAT like mkpf-budat,

end of it_mkpf.

data:begin of it_docs occurs 0,

MBLNR like mkpf-mblnr,

MJAHR like mkpf-mjahr,

end of it_docs.

*&&--Work area for column headings to FTP

DATA:BEGIN OF it_col,

cust(8),

name(13),

kunar1(20),

sname(35),

kunar2(20),

kunar3(20),

kunar4(20),

werks(5),

matnr(8),

maktx(11),

juice(5),

charg(5),

hsdat(15), "like mch1-hsdat, "production date

date1(17), "like mch1-vfdat, "customer expity date

date2(21), "like mch1-vfdat, "cliffstar expiry date

days(24), "days left to cust. expiry date

clabs(8), "like mchb-clabs,

ccase(13), "like mbew-stprs, "cost per case for finished

"goods

cgal(18), "like mbew-stprs, "juice cost per gal

budat(15), "last sale date

END OF it_col.

DATA: BEGIN OF DATA OCCURS 1,

COL1(20), COL2(45),

COL3(45), COL4(20),

COL5(20), COL6(20),

COL7(20), COL8(20),

COL9(20), COL10(20),

COL11(20), COL12(20),

COL13(20), COL14(20),

COL15(20), COL16(20),

COL17(20), COL18(20),

COL19(20), COL20(20),

  • COL21(20)

END OF DATA.

DATA: BEGIN OF FIELDNAME OCCURS 0,

COL1(60),

END OF FIELDNAME.

TYPES: typ_line(100).

DATA: w_unixfile LIKE cffile-filename,

w_rec1(1520) TYPE c, "EXPANDED FOR TITLES

w_rec(1520) TYPE c,

w_length TYPE i,

w_cmd(80) TYPE c,

w_hdl TYPE i,

w_key TYPE i VALUE 26101957,

w_idx LIKE sy-tabix,

w_dstlen TYPE i,

w_result TYPE STANDARD TABLE OF typ_line WITH HEADER LINE,

w_tempdate(10) TYPE c,

w_umren LIKE marm-umren,

w_umrez LIKE marm-umrez,

w_id1 LIKE sy-tabix,

w_id2 LIKE sy-tabix,

w_filest(550) TYPE c.

data v_filenm LIKE ibipparms-path.

INITIALIZATION.

CONCATENATE '/sapmnt/' sy-sysid '/global/extra/Report' INTO p_path.

v_str = p_file.

AT SELECTION-SCREEN ON p_filenm.

IF rd_ftp = 'X'.

IF p_filenm IS INITIAL.

MESSAGE 'Enter FTP file name' TYPE 'E'.

ENDIF.

ENDIF.

AT SELECTION-SCREEN ON p_file.

IF rd_pc = 'X'.

IF p_file IS INITIAL.

MESSAGE 'Enter Local file path' TYPE 'E'.

ENDIF.

IF NOT sy-batch IS INITIAL.

MESSAGE 'Execute the program in foreground mode only' TYPE 'E'.

ENDIF.

ENDIF.

START-OF-SELECTION.

v_idledt = sy-datum - p_day. "60.

**&&--get all batches

PERFORM get_batches.

PERFORM alloc_stock.

PERFORM get_dates.

PERFORM juice_style.

PERFORM get_cost.

PERFORM get_sales_person.

PERFORM get_last_sale_date.

IF rd_ftp = 'X'.

*&&--Get FTP data

PERFORM get_data_for_ftp.

*&&--pull data into crystal server via. FTP

PERFORM ftp_file.

ELSEIF rd_sap = 'X'.

SORT it_data BY matnr werks.

LOOP AT it_data.

MOVE: it_data-lab TO it_outtab-cust,

it_data-cust TO it_outtab-name,

it_data-kunar1 TO it_outtab-kunar1,

it_data-kunar2 TO it_outtab-kunar2,

it_data-kunar3 TO it_outtab-kunar3,

it_data-kunar4 TO it_outtab-kunar4,

it_data-werks TO it_outtab-werks,

it_data-matnr TO it_outtab-matnr,

it_data-maktx TO it_outtab-maktx,

it_data-juice TO it_outtab-juice,

it_data-charg TO it_outtab-charg,

it_data-hsdat TO it_outtab-hsdat,

it_data-date1 TO it_outtab-date1,

it_data-vfdat TO it_outtab-date2,

it_data-days TO it_outtab-days,

it_data-clabs TO it_outtab-clabs,

it_data-ccase TO it_outtab-ccase,

it_data-cgal TO it_outtab-cgal,

it_data-budat TO it_outtab-budat,

it_data-sname TO it_outtab-sname.

APPEND it_outtab.

CLEAR it_outtab.

ENDLOOP.

sort it_outtab by matnr ascending werks descending hsdat descending.

ELSEIF rd_pc = 'X'.

SORT it_data BY matnr werks.

LOOP AT it_data.

MOVE: it_data-lab TO it_outtab-cust,

it_data-cust TO it_outtab-name,

it_data-kunar1 TO it_outtab-kunar1,

it_data-kunar2 TO it_outtab-kunar2,

it_data-kunar3 TO it_outtab-kunar3,

it_data-kunar4 TO it_outtab-kunar4,

it_data-werks TO it_outtab-werks,

it_data-matnr TO it_outtab-matnr,

it_data-maktx TO it_outtab-maktx,

it_data-juice TO it_outtab-juice,

it_data-charg TO it_outtab-charg,

it_data-hsdat TO it_outtab-hsdat,

it_data-date1 TO it_outtab-date1,

it_data-vfdat TO it_outtab-date2,

it_data-days TO it_outtab-days,

it_data-clabs TO it_outtab-clabs,

it_data-ccase TO it_outtab-ccase,

it_data-cgal TO it_outtab-cgal,

it_data-budat TO it_outtab-budat,

it_data-sname TO it_outtab-sname.

APPEND it_outtab.

CLEAR it_outtab.

ENDLOOP.

sort it_outtab by matnr ascending werks descending hsdat descending.

v_str = p_file.

PERFORM EXPORT_TEXT_FILE.

  • PERFORM OPEN_EXCEL_FILE.

ENDIF.

TOP-OF-PAGE.

FORMAT COLOR COL_HEADING INTENSIFIED.

WRITE: /1(30) sy-repid.

WRITE: /1(10) sy-datum, 12(10) sy-uzeit.

FORMAT COLOR COL_HEADING INTENSIFIED OFF.

*##############END OF SELECTION#####################

END-OF-SELECTION.

format intensified on.

format color col_heading.

ULINE:/1(373).

WRITE: /1 sy-vline, (10) 'Customer',

sy-vline, (20) 'Customer name',

sy-vline, (20) 'Sales representative',

sy-vline, (25) 'Sales representative name',

sy-vline, (20) 'Customer service-1',

sy-vline, (20) 'Customer service-2',

sy-vline, (20) 'Customer service-3',

sy-vline, (5) 'Plant',

sy-vline, (15) 'Material',

sy-vline, (40) 'Description',

sy-vline, (6) 'Juice',

sy-vline, (10) 'Batch',

sy-vline, (15) 'Production date',

sy-vline, (13) 'Cust exp date',

sy-vline, (13) 'Clf exp. date',

sy-vline, (9) 'Days left',

sy-vline, (14) 'Last sale date',

sy-vline, (10) 'Batch qty.',

sy-vline, (13) 'Cost per case',

sy-vline, (14) 'Juice cost/gal',

sy-vline.

ULINE:/1(373).

format intensified off.

format color col_normal.

LOOP AT it_outtab.

WRITE: /1 sy-vline, (10) it_outtab-cust,

sy-vline, (20) it_outtab-name,

sy-vline, (20) it_outtab-kunar1,

sy-vline, (25) it_outtab-sname,

sy-vline, (20) it_outtab-kunar2,

sy-vline, (20) it_outtab-kunar3,

sy-vline, (20) it_outtab-kunar4,

sy-vline, (5) it_outtab-werks,

sy-vline, (15) it_outtab-matnr,

sy-vline, (40) it_outtab-maktx,

sy-vline, (6) it_outtab-juice,

sy-vline, (10) it_outtab-charg,

sy-vline, (15) it_outtab-hsdat,

sy-vline, (13) it_outtab-date1,

sy-vline, (13) it_outtab-date2,

sy-vline, (9) it_outtab-days,

sy-vline, (14) it_outtab-budat,

sy-vline, (10) it_outtab-clabs,

sy-vline, (13) it_outtab-ccase,

sy-vline, (14) it_outtab-cgal,

sy-vline.

ENDLOOP.

ULINE:/1(373).

SKIP 4.

SORT it_outtab BY matnr.

DELETE ADJACENT DUPLICATES FROM it_outtab COMPARING matnr.

FORMAT COLOR COL_HEADING INTENSIFIED.

ULINE:/1(59).

write: /1 sy-vline, (55) 'Materials with no juice style',

sy-vline.

ULINE:/1(59).

format intensified off.

format color col_normal.

data str(55).

LOOP AT it_outtab.

IF it_outtab-juice = ' '.

concatenate 'No juice style found for material: ' it_outtab-matnr

into str separated by space.

WRITE: /1 sy-vline, str,

  • (80) 'No juice style found for material: ',

  • it_outtab-matnr,

sy-vline.

ENDIF.

ENDLOOP.

ULINE:/1(59).

&----


*& Form get_batches

&----


  • get batches

----


  • --> p1 text

  • <-- p2 text

----


FORM get_batches.

data: v_date like sy-datum.

SELECT matnr werks lgort charg clabs

FROM mchb INTO TABLE it_mchb WHERE matnr LIKE 'F%' AND

clabs <> 0.

IF NOT it_mchb[] IS INITIAL.

SELECT matnr charg vfdat hsdat

FROM mch1 INTO TABLE it_mch1

FOR ALL ENTRIES IN it_mchb WHERE

matnr = it_mchb-matnr AND

charg = it_mchb-charg AND

  • vfdat GE sy-datum AND

hsdat LT v_idledt.

ENDIF.

SORT it_mchb BY matnr werks lgort charg.

SORT it_mch1 BY matnr charg.

LOOP AT it_mch1.

v_idx = sy-tabix.

READ TABLE it_mchb WITH KEY matnr = it_mch1-matnr

charg = it_mch1-charg

BINARY SEARCH.

v_idx = sy-tabix.

IF sy-subrc = 0.

it_data-matnr = it_mchb-matnr.

it_data-werks = it_mchb-werks.

it_data-lgort = it_mchb-lgort.

it_data-charg = it_mchb-charg.

it_data-clabs = it_mchb-clabs.

it_data-vfdat = it_mch1-vfdat.

it_data-hsdat = it_mch1-hsdat.

APPEND it_data.

CLEAR it_data.

ENDIF.

ENDLOOP.

ENDFORM. " get_batches

&----


*& Form alloc_stock

&----


  • allocate open quantities to batches

----


  • --> p1 text

  • <-- p2 text

----


FORM alloc_stock .

  • it_data1[] = it_data[].

  • SORT it_data1 BY matnr werks.

  • DELETE ADJACENT DUPLICATES FROM it_data1 COMPARING matnr werks.

**&&-- get open quantities for each material & plant

IF NOT it_data[] IS INITIAL.

SELECT *

INTO TABLE it_vbbe FROM vbbe

FOR ALL ENTRIES IN it_data

WHERE matnr = it_data-matnr AND

werks = it_data-werks.

ENDIF.

CLEAR: it_data, v_idx, v_qty.

SORT it_vbbe BY matnr werks.

LOOP AT it_vbbe.

it_qty-matnr = it_vbbe-matnr.

it_qty-werks = it_vbbe-werks.

it_qty-omeng = it_vbbe-omeng.

collect it_qty.

ENDLOOP.

SORT it_qty BY matnr werks.

SORT it_data BY matnr werks hsdat ASCENDING.

loop at it_qty.

loop at it_data where matnr = it_qty-matnr

and werks = it_qty-werks.

v_idx = sy-tabix.

it_qty-omeng = it_qty-omeng - it_data-clabs.

if it_qty-omeng lt 0.

it_data-clabs = it_qty-omeng * ( -1 ).

modify it_data index v_idx transporting clabs.

exit.

else.

delete it_data index v_idx.

endif.

endloop.

endloop.

***&&--allocate quantities to batches

  • LOOP AT it_data.

  • v_idx = sy-tabix.

  • READ TABLE it_qty WITH KEY matnr = it_data-matnr

  • werks = it_data-werks

  • BINARY SEARCH.

  • IF sy-subrc = 0.

  • v_idx1 = sy-tabix.

*

***&&-- we have enough open quantity to accomodate

  • IF it_data-clabs < it_qty-omeng.

  • it_qty-omeng = it_qty-omeng - it_data-clabs.

  • it_data-alloc_stat = 'A'.

  • it_data-alloc_qty = it_data-clabs.

  • MODIFY it_qty INDEX v_idx1 TRANSPORTING omeng.

  • CLEAR it_qty.

*

***&&-- open quantity is same as batch quantity

  • ELSEIF it_data-clabs = it_qty-omeng.

  • it_qty-omeng = it_qty-omeng - it_data-clabs.

  • it_data-alloc_stat = 'A'.

  • it_data-alloc_qty = it_data-clabs.

  • MODIFY it_qty INDEX v_idx1 TRANSPORTING omeng.

  • CLEAR it_qty.

*

***&&-- still some open quantity left to allocate a batch partially

  • ELSEIF it_data-clabs > it_qty-omeng AND it_qty-omeng GT 0.

  • it_data-alloc_qty = it_qty-omeng.

  • it_qty-omeng = it_qty-omeng - it_data-clabs.

  • it_data-alloc_stat = 'P'.

  • it_data-left_qty = it_qty-omeng.

  • MODIFY it_qty INDEX v_idx1 TRANSPORTING omeng.

  • CLEAR it_qty.

*

***&&-- no more open quantity for this material & plant

  • ELSEIF it_qty-omeng LE 0.

  • it_data-left_qty = it_data-clabs.

  • it_data-alloc_stat = 'U'.

  • ENDIF.

  • IF it_data-left_qty LT 0.

  • it_data-left_qty = it_data-left_qty * v_neg.

  • ENDIF.

  • MODIFY it_data INDEX v_idx TRANSPORTING alloc_stat

  • alloc_qty

  • left_qty.

  • CLEAR it_data.

  • ENDIF.

  • ENDLOOP.

CLEAR v_idx.

**&&-- get material description

IF NOT it_data[] IS INITIAL.

SELECT matnr maktx FROM makt

INTO TABLE it_makt FOR ALL ENTRIES IN it_data

WHERE matnr = it_data-matnr.

ENDIF.

SORT it_makt BY matnr.

LOOP AT it_data.

v_idx = sy-tabix.

READ TABLE it_makt WITH KEY matnr = it_data-matnr BINARY SEARCH.

IF sy-subrc = 0.

it_data-maktx = it_makt-maktx.

ENDIF.

MODIFY it_data INDEX v_idx TRANSPORTING maktx.

CLEAR: v_idx, it_data.

ENDLOOP.

ENDFORM. " alloc_stock

FORM get_dates .

DATA day TYPE i.

IF NOT it_data[] IS INITIAL.

SELECT matnr meins labor mhdrz mhdhb

FROM mara INTO TABLE it_mara

FOR ALL ENTRIES IN it_data WHERE matnr = it_data-matnr.

ENDIF.

CLEAR v_idx.

SORT it_mara BY matnr.

IF NOT it_mara[] IS INITIAL.

SELECT labor lbtxt FROM t024x INTO TABLE it_t024x

FOR ALL ENTRIES IN it_mara

WHERE spras = v_lang

AND labor = it_mara-labor.

ENDIF.

SORT it_t024x BY labor.

**&&-- get customer expiry date & laboratory office

LOOP AT it_data.

v_idx = sy-tabix.

READ TABLE it_mara WITH KEY matnr = it_data-matnr

BINARY SEARCH.

IF sy-subrc = 0.

READ TABLE it_t024x WITH KEY labor = it_mara-labor

BINARY SEARCH.

IF sy-subrc = 0.

it_data-lab = it_t024x-labor.

it_data-cust = it_t024x-lbtxt.

ENDIF.

IF it_mara-mhdrz <> 1.

it_data-date1 = it_data-hsdat + it_mara-mhdrz. "cust exp date

ELSE.

it_data-date1 = it_data-vfdat - 45. "cust exp date

ENDIF.

  • it_mchb-date2 = it_mchb-hsdat + it_mara-mhdrz. "mhdhb.

it_data-days = it_data-date1 - sy-datum.

it_data-meins = it_mara-meins.

MODIFY it_data INDEX v_idx TRANSPORTING date1

days cust

lab meins.

CLEAR it_data.

ENDIF.

ENDLOOP.

ENDFORM. " get_dates

&----


*& Form juice_style

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM juice_style .

**&&--collect all BOMs for materials and plant

IF NOT it_data[] IS INITIAL.

SELECT matnr werks stlnr stlal

FROM mast INTO CORRESPONDING FIELDS OF TABLE it_bom

FOR ALL ENTRIES IN it_data

WHERE matnr = it_data-matnr

AND werks = it_data-werks.

ENDIF.

SORT it_bom BY stlnr.

**&&--collect BOM header data for above collected BOMs

IF NOT it_bom[] IS INITIAL.

SELECT stlnr datuv

FROM stko INTO TABLE it_stko FOR ALL ENTRIES IN it_bom

WHERE stlty = 'M'

AND stlnr = it_bom-stlnr

AND stlal = it_bom-stlal.

ENDIF.

SORT it_stko BY stlnr ASCENDING datuv DESCENDING.

DELETE ADJACENT DUPLICATES FROM it_stko COMPARING stlnr.

CLEAR: v_idx.

**&&--populate "valid-from date" into it_bom so that to have all

**&&--material, plant, BOM & valid-from date altogether

LOOP AT it_bom.

v_idx = sy-tabix.

READ TABLE it_stko WITH KEY stlnr = it_bom-stlnr BINARY SEARCH.

IF sy-subrc = 0.

it_bom-valid_dt = it_stko-datuv.

MODIFY it_bom INDEX v_idx TRANSPORTING valid_dt.

CLEAR:it_bom, v_idx.

ENDIF.

ENDLOOP.

SORT it_bom BY stlnr valid_dt idnrk.

**&&--collect BOM item data to collect BOM component

IF NOT it_bom[] IS INITIAL.

SELECT stlnr

datuv

idnrk

menge FROM stpo INTO TABLE it_stpo

FOR ALL ENTRIES IN it_bom WHERE stlty = 'M' AND

stlnr = it_bom-stlnr AND

datuv = it_bom-valid_dt AND

idnrk LIKE 'J%'. "like 'J*'.

ENDIF.

SORT it_stpo BY stlnr datuv.

SORT it_bom BY stlnr valid_dt.

CLEAR:v_idx.

LOOP AT it_stpo.

IF it_stpo-idnrk CP 'J*'.

READ TABLE it_bom WITH KEY stlnr = it_stpo-stlnr

valid_dt = it_stpo-datuv

BINARY SEARCH.

IF sy-subrc = 0.

v_idx = sy-tabix.

it_bom-idnrk = it_stpo-idnrk.

MODIFY it_bom INDEX v_idx TRANSPORTING idnrk.

CLEAR:v_idx, it_bom.

ENDIF.

ENDIF.

ENDLOOP.

SORT it_bom BY matnr werks.

CLEAR v_idx.

LOOP AT it_data.

v_idx = sy-tabix.

READ TABLE it_bom WITH KEY matnr = it_data-matnr

werks = it_data-werks

BINARY SEARCH.

IF sy-subrc = 0.

it_data-juice = it_bom-idnrk(18).

MODIFY it_data INDEX v_idx TRANSPORTING juice.

CLEAR:v_idx, it_data.

ENDIF.

ENDLOOP.

ENDFORM. " juice_style

&----


*& Form get_cost

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_cost .

IF NOT it_data[] IS INITIAL.

SELECT matnr

bwkey

stprs

peinh FROM mbew INTO TABLE it_mbew FOR ALL

ENTRIES IN it_data WHERE matnr = it_data-matnr AND

bwkey = it_data-werks.

ENDIF.

CLEAR v_idx.

SORT it_mbew BY matnr bwkey.

LOOP AT it_data.

v_idx = sy-tabix.

READ TABLE it_mbew WITH KEY matnr = it_data-matnr

bwkey = it_data-werks

BINARY SEARCH.

IF sy-subrc = 0.

it_data-ccase = it_mbew-stprs / it_mbew-peinh.

MODIFY it_data INDEX v_idx TRANSPORTING ccase.

CLEAR:it_data, v_idx.

ENDIF.

ENDLOOP.

****Juice cost per gallon

CLEAR:it_mbew, v_idx.

REFRESH it_mbew.

SORT it_data BY juice werks.

IF NOT it_data[] IS INITIAL.

SELECT matnr

bwkey

stprs

peinh FROM mbew INTO TABLE it_mbew FOR ALL

ENTRIES IN it_data WHERE matnr = it_data-juice AND

bwkey = it_data-werks.

ENDIF.

SORT it_mbew BY matnr bwkey.

SORT it_data BY juice werks.

SORT it_stpo BY stlnr datuv. "idnrk.

LOOP AT it_data.

v_idx = sy-tabix.

READ TABLE it_mbew WITH KEY matnr = it_data-juice

bwkey = it_data-werks

BINARY SEARCH.

IF sy-subrc = 0.

clear it_bom.

read table it_bom with key matnr = it_data-matnr

werks = it_data-werks

binary search.

IF sy-subrc = 0.

READ TABLE it_stpo WITH KEY stlnr = it_bom-stlnr

datuv = it_bom-valid_dt

binary search.

IF sy-subrc = 0.

it_data-cgal = ( ( it_stpo-menge / it_mbew-peinh )

  • ( it_mbew-stprs / it_mbew-peinh ) ).

MODIFY it_data INDEX v_idx TRANSPORTING cgal.

CLEAR: v_idx, it_data.

ENDIF.

ELSE.

ENDIF.

ENDIF.

ENDLOOP.

ENDFORM. " get_cost

FORM get_data_for_ftp .

SORT it_data BY matnr werks.

LOOP AT it_data.

MOVE: it_data-lab TO it_outtab-cust,

it_data-cust TO it_outtab-name,

it_data-kunar1 TO it_outtab-kunar1,

it_data-sname TO it_outtab-sname,

it_data-kunar2 TO it_outtab-kunar2,

it_data-kunar3 TO it_outtab-kunar3,

it_data-kunar4 TO it_outtab-kunar4,

it_data-werks TO it_outtab-werks,

it_data-matnr TO it_outtab-matnr,

it_data-maktx TO it_outtab-maktx,

it_data-juice TO it_outtab-juice,

it_data-charg TO it_outtab-charg,

it_data-hsdat TO it_outtab-hsdat,

it_data-date1 TO it_outtab-date1,

it_data-vfdat TO it_outtab-date2,

it_data-days TO it_outtab-days,

it_data-budat TO it_outtab-budat,

it_data-clabs TO it_outtab-clabs,

it_data-ccase TO it_outtab-ccase,

it_data-cgal TO it_outtab-cgal.

APPEND it_outtab.

CLEAR it_outtab.

ENDLOOP.

sort it_outtab by matnr ascending werks descending hsdat descending.

DATA: vdat LIKE sy-datum,

w_tempdate(10) TYPE c.

LOOP AT it_outtab.

MOVE: it_outtab-cust TO it_ftp-cust,

it_outtab-name TO it_ftp-name,

it_outtab-werks TO it_ftp-werks,

it_outtab-matnr TO it_ftp-matnr,

it_outtab-maktx TO it_ftp-maktx,

it_outtab-juice TO it_ftp-juice,

it_outtab-charg TO it_ftp-charg.

vdat = it_outtab-hsdat.

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

EXPORTING

date_internal = vdat

IMPORTING

date_external = w_tempdate

EXCEPTIONS

date_internal_is_invalid = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

MOVE w_tempdate TO it_ftp-hsdat.

CLEAR: w_tempdate, vdat.

vdat = it_outtab-date1.

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

EXPORTING

date_internal = vdat

IMPORTING

date_external = w_tempdate

EXCEPTIONS

date_internal_is_invalid = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

MOVE w_tempdate TO it_ftp-date1.

CLEAR: w_tempdate, vdat.

vdat = it_outtab-date2.

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

EXPORTING

date_internal = vdat

IMPORTING

date_external = w_tempdate

EXCEPTIONS

date_internal_is_invalid = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

MOVE w_tempdate TO it_ftp-date2.

CLEAR: w_tempdate, vdat.

vdat = it_outtab-budat.

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

EXPORTING

date_internal = vdat

IMPORTING

date_external = w_tempdate

EXCEPTIONS

date_internal_is_invalid = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

MOVE w_tempdate TO it_ftp-budat.

CLEAR: w_tempdate, vdat.

MOVE: it_outtab-days TO it_ftp-days,

it_outtab-clabs TO it_ftp-clabs,

it_outtab-ccase TO it_ftp-ccase,

it_outtab-kunar1 TO it_ftp-kunar1,

it_outtab-sname TO it_ftp-sname,

it_outtab-kunar2 TO it_ftp-kunar2,

it_outtab-kunar3 TO it_ftp-kunar3,

it_outtab-kunar4 TO it_ftp-kunar4,

it_outtab-cgal TO it_ftp-cgal.

APPEND it_ftp.

CLEAR it_ftp.

ENDLOOP.

ENDFORM. " GET_DATA_FOR_FTP

*&______________________________________________________________________

*& Form FTP_FILE

*&______________________________________________________________________

  • outputs to FTP

*&______________________________________________________________________

  • --> p1 text

  • <-- p2 text

*&______________________________________________________________________

FORM ftp_file .

DESCRIBE FIELD p_pwd LENGTH w_dstlen IN CHARACTER MODE.

CALL 'AB_RFC_X_SCRAMBLE_STRING'

ID 'SOURCE' FIELD p_pwd ID 'KEY' FIELD w_key

ID 'SCR' FIELD 'X' ID 'DESTINATION' FIELD p_pwd

ID 'DSTLEN' FIELD w_dstlen.

CALL FUNCTION 'FTP_CONNECT'

EXPORTING

user = p_user

password = p_pwd

host = p_host

rfc_destination = p_dest

IMPORTING

handle = w_hdl.

CONCATENATE 'cd' p_dir INTO w_cmd SEPARATED BY space.

CALL FUNCTION 'FTP_COMMAND'

EXPORTING

handle = w_hdl

command = w_cmd

compress = p_comp

TABLES

data = w_result

EXCEPTIONS

command_error = 1

OTHERS = 2.

LOOP AT w_result.

WRITE AT / w_result.

ENDLOOP.

REFRESH w_result. CLEAR w_result.

CLEAR w_cmd.

CONCATENATE 'lcd' p_path INTO w_cmd SEPARATED BY space.

CALL FUNCTION 'FTP_COMMAND'

EXPORTING

handle = w_hdl

command = w_cmd

TABLES

data = w_result

EXCEPTIONS

command_error = 1

tcpip_error = 2.

LOOP AT w_result.

WRITE AT / w_result.

ENDLOOP.

REFRESH w_result. CLEAR w_result.

CLEAR w_cmd.

CONCATENATE 'ascii' ' ' INTO w_cmd SEPARATED BY space.

CALL FUNCTION 'FTP_COMMAND'

EXPORTING

handle = w_hdl

command = w_cmd

TABLES

data = w_result

EXCEPTIONS

command_error = 1

tcpip_error = 2.

LOOP AT w_result.

WRITE AT / w_result.

ENDLOOP.

PERFORM send_transfer_status.

REFRESH w_result. CLEAR w_result.

CONCATENATE 'put' p_filenm INTO w_cmd SEPARATED BY space.

CALL FUNCTION 'FTP_COMMAND'

EXPORTING

handle = w_hdl

command = w_cmd

TABLES

data = w_result

EXCEPTIONS

command_error = 1

tcpip_error = 2.

LOOP AT w_result.

WRITE AT / w_result.

ENDLOOP.

PERFORM send_transfer_status.

REFRESH w_result.

CONCATENATE p_path '/' p_filenm INTO w_unixfile.

OPEN DATASET w_unixfile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc = 0.

PERFORM titel_data.

PERFORM ftp_fill_data.

CLOSE DATASET w_unixfile.

CONCATENATE 'put' p_filenm INTO w_cmd SEPARATED BY space.

CALL FUNCTION 'FTP_COMMAND'

EXPORTING

handle = w_hdl

command = w_cmd

TABLES

data = w_result

EXCEPTIONS

command_error = 1

tcpip_error = 2.

LOOP AT w_result.

WRITE AT / w_result.

ENDLOOP.

ENDIF.

CALL FUNCTION 'FTP_DISCONNECT'

EXPORTING

handle = w_hdl.

ENDFORM. "FTP_FILE

*&______________________________________________________________________

*& FORM SEND_TRANSFER_STATUS

*&______________________________________________________________________

FORM send_transfer_status.

w_filest = 'TEMP.TXT'.

CONCATENATE p_path '/' w_filest INTO w_unixfile.

OPEN DATASET w_unixfile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

CHECK sy-subrc = 0.

LOOP AT w_result.

TRANSFER w_result TO w_unixfile LENGTH 200.

ENDLOOP.

CLOSE DATASET w_unixfile.

CONCATENATE 'put' w_filest INTO w_cmd SEPARATED BY space.

CALL FUNCTION 'FTP_COMMAND'

EXPORTING

handle = w_hdl

command = w_cmd

TABLES

data = w_result

EXCEPTIONS

command_error = 1

tcpip_error = 2.

ENDFORM. " FTP_FILE

*&______________________________________________________________________

*& FORM TITEL_DATA

*&______________________________________________________________________

FORM titel_data.

it_col-cust = 'Customer'.

it_col-name = 'Customer name'.

it_col-kunar1 = 'Sales representative'.

it_col-sname = 'Sales representative name'.

it_col-kunar2 = 'Customer service-1'.

it_col-kunar3 = 'Customer service-2'.

it_col-kunar4 = 'Customer service-3'.

it_col-werks = 'Plant'.

it_col-matnr = 'Material'.

it_col-maktx = 'Description'.

it_col-juice = 'Juice'.

it_col-charg = 'Batch'.

it_col-hsdat = 'Production date'.

it_col-date1 = 'Cust. expiry date'.

it_col-date2 = 'Cliffstar expiry date'.

it_col-days = 'Days to cust expiry date'.

it_col-clabs = 'Quantity'.

it_col-ccase = 'Cost per case'.

it_col-cgal = 'Juice cost per gal'.

it_col-budat = 'Last sale date'.

w_length = 350.

CLEAR w_rec1.

CONCATENATE

it_col-cust it_col-name

it_col-kunar1 it_col-sname

it_col-kunar2 it_col-kunar3

it_col-kunar4 it_col-werks

it_col-matnr

it_col-maktx it_col-juice

it_col-charg it_col-hsdat

it_col-date1 it_col-date2

it_col-days it_col-budat

it_col-clabs

it_col-ccase it_col-cgal

INTO w_rec1 SEPARATED BY c_tab.

TRANSFER w_rec1 TO w_unixfile." LENGTH w_length.

ENDFORM. " FTP_FILE

*&______________________________________________________________________

  • FORM FTP_FILL_DATA *

*&______________________________________________________________________

  • ........ *

*&______________________________________________________________________

FORM ftp_fill_data.

  • SORT it_ftp BY name1 werks.

w_length = 350.

LOOP AT it_ftp.

CONCATENATE

it_ftp-cust it_ftp-name

it_ftp-kunar1 it_ftp-sname

it_ftp-kunar2 it_ftp-kunar3

it_ftp-kunar4

it_ftp-werks it_ftp-matnr

it_ftp-maktx it_ftp-juice

it_ftp-charg it_ftp-hsdat

it_ftp-date1 it_ftp-date2

it_ftp-days it_ftp-budat

it_ftp-clabs

it_ftp-ccase it_ftp-cgal

INTO w_rec SEPARATED BY c_tab.

TRANSFER w_rec TO w_unixfile." LENGTH w_length.

ENDLOOP.

ENDFORM. "FTP_FILL_DATA

&----


*& Form get_sales_person

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_sales_person.

data:begin of it_zlaboffice occurs 0,

labor like zlaboffice-labor,

kunar1 like zlaboffice-kunar1,

kunar2 like zlaboffice-kunar2,

kunar3 like zlaboffice-kunar3,

kunar4 like zlaboffice-kunar4,

end of it_zlaboffice.

if not it_data[] is initial.

select labor

kunar1

kunar2

kunar3

kunar4

from zlaboffice into table it_zlaboffice for all entries in

it_data where labor = it_data-lab.

endif.

sort it_zlaboffice by labor.

loop at it_data.

v_idx = sy-tabix.

read table it_zlaboffice with key labor = it_data-lab

binary search.

if sy-subrc = 0.

it_data-kunar1 = it_zlaboffice-kunar1.

it_data-kunar2 = it_zlaboffice-kunar2.

it_data-kunar3 = it_zlaboffice-kunar3.

it_data-kunar4 = it_zlaboffice-kunar4.

modify it_data index v_idx transporting kunar1 kunar2

kunar3 kunar4.

clear:v_idx.

endif.

endloop.

data:begin of it_kna1 occurs 0,

kunnr like kna1-kunnr,

name1 like kna1-name1,

end of it_kna1.

**&--sales representative name

clear v_idx.

if not it_data[] is initial.

select kunnr name1 from kna1 into table it_kna1 for all entries in

it_data where kunnr = it_data-kunar1.

endif.

sort it_kna1 by kunnr.

loop at it_data.

v_idx = sy-tabix.

read table it_kna1 with key kunnr = it_data-kunar1 binary search.

if sy-subrc = 0.

it_data-sname = it_kna1-name1.

modify it_data index v_idx transporting sname.

clear:it_data, v_idx.

endif.

endloop.

endform. " get_sales_person

&----


*& get last sale date

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_last_sale_date .

data: begin of it_mtrl occurs 0,

matnr like mseg-matnr,

werks like mseg-werks,

lgort like mseg-lgort,

end of it_mtrl.

loop at it_data.

it_mtrl-matnr = it_data-matnr.

it_mtrl-werks = it_data-werks.

it_mtrl-lgort = it_data-lgort.

collect it_mtrl.

endloop.

sort it_mtrl by matnr werks lgort.

delete adjacent duplicates from it_mtrl comparing all fields.

if not it_mtrl[] is initial.

**select mblnr mjahr matnr werks lgort from mseg into table

**it_mseg for all entries in it_mtrl where bwart = '601'

  • and matnr = it_mtrl-matnr

  • and werks = it_mtrl-werks

  • and lgort = it_mtrl-lgort

  • and sobkz = ' '.

select mblnr mjahr matnr werks lgort from mseg into table

it_mseg for all entries in it_mtrl where matnr = it_mtrl-matnr

and werks = it_mtrl-werks

and lgort = it_mtrl-lgort

and bwart = '601'

and sobkz = ' '.

**

endif.

*SORT it_mseg by mblnr mjahr hsdat descending.

*delete adjacent duplicates from it_mseg comparing mblnr.

sort it_mseg by werks ascending matnr ascending

mjahr descending mblnr descending.

delete adjacent duplicates from it_mseg comparing matnr werks.

if not it_mseg[] is initial.

select mblnr mjahr budat from mkpf into table it_mkpf

for all entries in it_mseg

where mblnr = it_mseg-mblnr

and mjahr = it_mseg-mjahr.

endif.

SORT it_mseg by matnr werks lgort.

sort it_mkpf by mblnr mjahr.

clear v_idx.

loop at it_data.

v_idx = sy-tabix.

read table it_mseg with key matnr = it_data-matnr

werks = it_data-werks

lgort = it_data-lgort

binary search.

if sy-subrc = 0.

read table it_mkpf with key mblnr = it_mseg-mblnr

mjahr = it_mseg-mjahr

binary search.

if sy-subrc = 0.

it_data-budat = it_mkpf-budat.

modify it_data index v_idx transporting budat.

clear:it_data, v_idx.

endif.

endif.

endloop.

endform. " get_last_sale_date

&----


*& Form EXPORT_TEXT_FILE.

&----


FORM EXPORT_TEXT_FILE.

REFRESH DATA. CLEAR DATA.

data temp_date like sy-datum.

sort it_outtab by matnr ascending werks descending

hsdat descending.

data-col1 = 'Material'.

data-col2 = 'Description'.

data-col3 = 'Plant'.

data-col4 = 'Batch'.

data-col5 = 'Batch qty.'.

data-col6 = 'Production date'.

data-col7 = 'Cust exp date'.

data-col8 = 'Days left'.

data-col9 = 'Clf exp date'.

data-col10 = 'Last sale date'.

data-col11 = 'Cost per case'.

data-col12 = 'Juice cost/gal'.

data-col13 = 'Customer service-1'.

data-col14 = 'Customer service-2'.

data-col15 = 'Customer service-3'.

data-col16 = 'Sales representative'.

append data.

clear data.

LOOP AT it_outtab.

MOVE: it_outtab-matnr TO data-col1,

it_outtab-maktx TO data-col2,

it_outtab-werks TO data-col3,

it_outtab-charg TO data-col4,

it_outtab-clabs TO data-col5.

temp_date = it_outtab-hsdat.

write:temp_date using edit mask '__/__/____' TO DATA-COL6.

clear temp_date.

temp_date = it_outtab-date1.

write:temp_date using edit mask '__/__/____' TO DATA-COL7.

clear temp_date.

MOVE: it_outtab-days TO data-col8.

temp_date = it_outtab-date2.

WRITE:temp_date using edit mask '__/__/____' TO DATA-COL9.

clear temp_date.

temp_date = it_outtab-budat.

WRITE:temp_date using edit mask '__/__/____' TO DATA-COL10.

clear temp_date.

MOVE: it_outtab-ccase TO data-col11,

it_outtab-cgal TO data-col12,

it_outtab-kunar2 TO data-col13,

it_outtab-kunar3 TO data-col14,

it_outtab-kunar4 TO data-col15,

it_outtab-sname TO data-col16.

append data.

clear data.

ENDLOOP.

PERFORM DOWNLOAD_TO_FLATFILE TABLES DATA FIELDNAME

USING P_FILE.

DESCRIBE TABLE IT_DATA LINES SY-TABIX.

MESSAGE S016(PS) WITH P_FILE SY-TABIX..

ENDFORM.

----


  • FORM DOWNLOAD_TO_FLATFILE *

----


  • ........ *

----


  • --> P_DATA *

  • --> P_FIELDNAMES *

  • --> P_FILE_NAME *

----


FORM DOWNLOAD_TO_FLATFILE TABLES P_DATA STRUCTURE DATA

P_FIELDNAMES STRUCTURE FIELDNAME

USING P_FILE_NAME.

data str1 type string.

str1 = p_file_name.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

filename = str1

FILETYPE = 'ASC'

  • APPEND = ' '

WRITE_FIELD_SEPARATOR = 'X'

  • IMPORTING

  • FILELENGTH =

tables

data_tab = data

  • FIELDNAMES =

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

NO_AUTHORITY = 5

UNKNOWN_ERROR = 6

HEADER_NOT_ALLOWED = 7

SEPARATOR_NOT_ALLOWED = 8

FILESIZE_NOT_ALLOWED = 9

HEADER_TOO_LONG = 10

DP_ERROR_CREATE = 11

DP_ERROR_SEND = 12

DP_ERROR_WRITE = 13

UNKNOWN_DP_ERROR = 14

ACCESS_DENIED = 15

DP_OUT_OF_MEMORY = 16

DISK_FULL = 17

DP_TIMEOUT = 18

FILE_NOT_FOUND = 19

DATAPROVIDER_EXCEPTION = 20

CONTROL_FLUSH_ERROR = 21

OTHERS = 22

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " DOWNLOAD_TO_FLATFILE