Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

File Creation direct into Application Server

Former Member
0 Kudos
200

Hi,

I want to CREATE .txt file direct on Application server, using open dataset for output. Application operation system is Sun Sol. Please write if you know regarding this.

Vijay

2 REPLIES 2

Former Member
0 Kudos
66

Hi ,

Go through the following code :-

tables : zerp_extract_anr.

*Declearation Of Internal Table : i_contracts1

data : begin of i_contracts1 occurs 0,

ebeln like ekko-ebeln,

i1 value 'Ï',

waers1(5),

i2 value 'Ï',

date1(10),

i3 value 'Ï',

date2(10),

i4 value 'Ï',

ekorg1 like ekko-ekorg,

i5 value 'Ï',

lifnr like ekko-lifnr,

i6 value 'Ï',

ekgrp like ekko-ekgrp,

i7 value 'Ï',

zterm like ekko-zterm,

i8 value 'Ï',

bukrs like ekko-bukrs,

i9 value 'Ï',

inco1 like ekko-inco1,

i10 value 'Ï',

inco2 like ekko-inco2,

i11 value 'Ï',

ktwrt(20),

i12 value 'Ï',

waers2(5),

i13 value 'Ï',

ekorg2 like ekko-ekorg,

end of i_contracts1.

*Declearation Of Internal Table : i_contracts2

data : begin of i_contracts2 occurs 0,

ebeln like ekpo-ebeln,

i1 value 'Ï',

ebelp like ekpo-ebelp,

i2 value 'Ï',

matnr like ekpo-matnr,

i3 value 'Ï',

werks like ekpo-werks,

i4 value 'Ï',

txz01 like ekpo-txz01,

i5 value 'Ï',

matkl like ekpo-matkl,

i6 value 'Ï',

meins1(3),

i7 value 'Ï',

brtwr(16),

i8 value 'Ï',

bprme1(3),

i9 value 'Ï',

menge(17),

i10 value 'Ï',

meins2(3),

i11 value 'Ï',

waers(5), "absent

i12 value 'Ï',

mwskz like ekpo-mwskz,

i13 value 'Ï',

bprme2(3),

i14 value 'Ï',

netpr(14),

i15 value 'Ï',

untto(4),

i16 value 'Ï',

uebto(4),

i17 value 'Ï',

uebtk like ekpo-uebtk,

i18 value 'Ï',

loekz like ekpo-loekz,

end of i_contracts2.

*Declearation Of Internal Table : i_contracts3

data : begin of i_contracts3 occurs 0,

ebeln like ekpa-ebeln,

i1 value 'Ï',

ebelp like ekpa-ebelp,

i2 value 'Ï',

parvw like ekpa-parvw,

i3 value 'Ï',

lifn2 like ekpa-lifn2,

end of i_contracts3.

*Declearation Of Internal Table : i_contracts4

data : begin of i_contracts4 occurs 0,

ebeln like ekko-ebeln,

i1 value 'Ï',

ebelp like ekpo-ebelp,

i2 value 'Ï',

kschl like konv-kschl,

i3 value 'Ï',

kmein(3),

i4 value 'Ï',

waers(5),

i5 value 'Ï',

kpein(5),

i6 value 'Ï',

kawrt(21),

end of i_contracts4.

*Declearation Of Internal Table : i_contracts5

data : begin of i_contracts5 occurs 0,

ebeln like ekpo-ebeln,

i1 value 'Ï',

ebelp like ekpo-ebelp,

i2 value 'Ï',

tdid like thead-tdid,

i3 value 'Ï',

tdline like tline-tdline,

end of i_contracts5.

*Declearation Of Internal Table : i_ekpo

data : begin of i_ekpo occurs 0,

ebeln like ekpo-ebeln,

ebelp like ekpo-ebelp,

matnr like ekpo-matnr,

werks like ekpo-werks,

txz01 like ekpo-txz01,

matkl like ekpo-matkl,

brtwr like ekpo-brtwr,

bprme like ekpo-bprme,

menge like ekpo-menge,

meins like ekpo-meins,

mwskz like ekpo-mwskz,

netpr like ekpo-netpr,

untto like ekpo-untto,

uebto like ekpo-uebto,

uebtk like ekpo-uebtk,

loekz like ekpo-loekz,

end of i_ekpo.

*Declearation Of Internal Table : i_ekko

data : begin of i_ekko occurs 0,

ebeln like ekko-ebeln,

waers like ekko-waers,

kdatb like ekko-kdatb,

kdate like ekko-kdate,

ekorg like ekko-ekorg,

lifnr like ekko-lifnr,

ekgrp like ekko-ekgrp,

zterm like ekko-zterm,

bukrs like ekko-bukrs,

inco1 like ekko-inco1,

inco2 like ekko-inco2,

ktwrt like ekko-ktwrt,

knumv like ekko-knumv,

end of i_ekko.

*Declearation Of Internal Table : i_ekpa

data : begin of i_ekpa occurs 0,

ebeln like ekpa-ebeln,

ebelp like ekpa-ebelp,

parvw like ekpa-parvw,

lifn2 like ekpa-lifn2,

end of i_ekpa.

*Declearation Of Internal Table : i_konv

data : begin of i_konv occurs 0,

knumv like konv-knumv,

kschl like konv-kschl,

kmein like konv-kmein,

waers like konv-waers,

kpein like konv-kpein,

KAWRT like konv-KAWRT,

end of i_konv.

*Declearation Of Internal Table : h_text

data: begin of h_text occurs 0.

include structure thead.

data: end of h_text.

*Declearation Of Internal Table : text_lines

data: begin of text_lines occurs 0.

include structure tline.

data: end of text_lines.

data : w_name(70).

*Variable For Object Name

data: obj_name(10) type c value 'SCM_C_46'.

*Variable For Datadrop

data : datadrop(4).

data: ln type i.

*Variable For Hash Field

data: cnt1(20),cnt2(20),cnt3(20),cnt4(20),cnt5(20).

data : date1(10),

date2(10).

*Variable For Data Sets

data : dataset1 like rlgrap-filename value '/var/sapgl/migrate',

dataset2 like rlgrap-filename value '/var/sapgl/migrate',

dataset3 like rlgrap-filename value '/var/sapgl/migrate',

dataset4 like rlgrap-filename value '/var/sapgl/migrate',

dataset5 like rlgrap-filename value '/var/sapgl/migrate'.

**Selection Screen

selection-screen skip 2.

selection-screen begin of block b1 with frame title text-t01.

parameters : mc1 radiobutton group rad1,

mc2 radiobutton group rad1,

mc3 radiobutton group rad1,

im1 radiobutton group rad1,

tr1 radiobutton group rad1 default 'X',

pt1 radiobutton group rad1.

selection-screen end of block b1.

at selection-screen on radiobutton group rad1.

if mc1 = 'X'.

datadrop = '/MC1'.

elseif mc2 = 'X'.

datadrop = '/MC2'.

elseif mc3 = 'X'.

datadrop = '/MC3'.

elseif im1 = 'X'.

datadrop = '/IM1'.

elseif tr1 = 'X'.

datadrop = '/TR1'.

elseif pt1 = 'X'.

datadrop = '/PT1'.

endif.

    • start of selection

start-of-selection.

*Subroutine To Select The Data

perform select_data.

*Subroutine To Process The Data

perform process_data.

*Down Load The Data To The Application Server

perform download_app_server.

*&----


*

FORM select_data.

data : v1(3) value '26%',

v2(3) value '46%',

v3(3) value '66%',

v4(2) value 'C%',

v5(2) value 'N%'.

*select data from EKPO

select ebeln ebelp matnr werks txz01 matkl brtwr bprme

menge meins mwskz netpr untto uebto uebtk loekz

from ekpo into table i_ekpo

where ( ebeln like v1 or

ebeln like v2 or

ebeln like v3 or

ebeln like v4 or

ebeln like v5 )

and werks not in ('ADMN','LGHS','XO01','NGM1','ADMM').

sort i_ekpo by ebeln ebelp.

*select data from EKKO

if not i_ekpo[] is initial.

select ebeln waers kdatb kdate ekorg lifnr ekgrp

zterm bukrs inco1 inco2 ktwrt knumv

from ekko into table i_ekko for all entries in i_ekpo

where ebeln = i_ekpo-ebeln

and kdate ge '20071001'."R001

endif.

*select data from EKPA

if not i_ekpo[] is initial.

select ebeln ebelp parvw lifn2

from ekpa into table i_ekpa for all entries in i_ekpo

where ebeln = i_ekpo-ebeln

and werks = i_ekpo-werks.

endif.

*select data from KONV

if not i_ekko[] is initial.

select knumv kschl kmein waers kpein kawrt

from konv into table i_konv for all entries in i_ekko

where knumv = i_ekko-knumv.

endif.

ENDFORM. " select_data

*&----


*

FORM process_data.

loop at i_ekpo.

i_contracts2-ebeln = i_ekpo-ebeln.

i_contracts2-ebelp = i_ekpo-ebelp.

i_contracts2-matnr = i_ekpo-matnr.

i_contracts2-werks = i_ekpo-werks.

i_contracts2-txz01 = i_ekpo-txz01.

i_contracts2-matkl = i_ekpo-matkl.

i_contracts2-meins1 = i_ekpo-meins.

i_contracts2-meins2 = i_ekpo-meins.

i_contracts2-brtwr = i_ekpo-brtwr.

i_contracts2-bprme1 = i_ekpo-bprme.

i_contracts2-bprme2 = i_ekpo-bprme.

i_contracts2-menge = i_ekpo-menge.

i_contracts2-waers = ' '.

i_contracts2-mwskz = i_ekpo-mwskz.

i_contracts2-netpr = i_ekpo-netpr.

i_contracts2-untto = i_ekpo-untto.

i_contracts2-uebto = i_ekpo-uebto.

i_contracts2-uebtk = i_ekpo-uebtk.

i_contracts2-loekz = i_ekpo-loekz.

i_contracts2-i1 = 'Ï'.

i_contracts2-i2 = 'Ï'.

i_contracts2-i3 = 'Ï'.

i_contracts2-i4 = 'Ï'.

i_contracts2-i5 = 'Ï'.

i_contracts2-i6 = 'Ï'.

i_contracts2-i7 = 'Ï'.

i_contracts2-i8 = 'Ï'.

i_contracts2-i9 = 'Ï'.

i_contracts2-i10 = 'Ï'.

i_contracts2-i11 = 'Ï'.

i_contracts2-i12 = 'Ï'.

i_contracts2-i13 = 'Ï'.

i_contracts2-i14 = 'Ï'.

i_contracts2-i15 = 'Ï'.

i_contracts2-i16 = 'Ï'.

i_contracts2-i17 = 'Ï'.

i_contracts2-i18 = 'Ï'.

append i_contracts2.

clear i_contracts2.

**get standard Texts for K01

clear w_name.

concatenate i_ekpo-ebeln i_ekpo-ebelp into w_name.

CALL FUNCTION 'READ_TEXT'

EXPORTING

ID = 'K01'

LANGUAGE = 'E'

NAME = w_name

OBJECT = 'EKPO'

IMPORTING

HEADER = h_text

TABLES

LINES = text_lines

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 = 0.

read table text_lines index 1.

if sy-subrc = 0.

i_contracts5-tdline = text_lines-tdline.

endif.

endif.

i_contracts5-ebeln = i_ekpo-ebeln.

i_contracts5-ebelp = i_ekpo-ebelp.

i_contracts5-tdid = 'K01'.

i_contracts5-i1 = 'Ï'.

i_contracts5-i2 = 'Ï'.

i_contracts5-i3 = 'Ï'.

append i_contracts5.

clear : i_contracts5, h_text, text_lines.

**get standard Texts for K02

CALL FUNCTION 'READ_TEXT'

EXPORTING

ID = 'K02'

LANGUAGE = 'E'

NAME = w_name

OBJECT = 'EKPO'

IMPORTING

HEADER = h_text

TABLES

LINES = text_lines

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 = 0.

read table text_lines index 1.

if sy-subrc = 0.

i_contracts5-tdline = text_lines-tdline.

endif.

endif.

i_contracts5-ebeln = i_ekpo-ebeln.

i_contracts5-ebelp = i_ekpo-ebelp.

i_contracts5-tdid = 'K02'.

i_contracts5-i1 = 'Ï'.

i_contracts5-i2 = 'Ï'.

i_contracts5-i3 = 'Ï'.

append i_contracts5.

clear : i_contracts5, h_text, text_lines.

**get standard Texts for K03

CALL FUNCTION 'READ_TEXT'

EXPORTING

ID = 'K03'

LANGUAGE = 'E'

NAME = w_name

OBJECT = 'EKPO'

IMPORTING

HEADER = h_text

TABLES

LINES = text_lines

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 = 0.

read table text_lines index 1.

if sy-subrc = 0.

i_contracts5-tdline = text_lines-tdline.

endif.

endif.

i_contracts5-ebeln = i_ekpo-ebeln.

i_contracts5-ebelp = i_ekpo-ebelp.

i_contracts5-tdid = 'K03'.

i_contracts5-i1 = 'Ï'.

i_contracts5-i2 = 'Ï'.

i_contracts5-i3 = 'Ï'.

append i_contracts5.

clear : i_contracts5, h_text, text_lines.

**get standard Texts for K04

CALL FUNCTION 'READ_TEXT'

EXPORTING

ID = 'K04'

LANGUAGE = 'E'

NAME = w_name

OBJECT = 'EKPO'

IMPORTING

HEADER = h_text

TABLES

LINES = text_lines

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 = 0.

read table text_lines index 1.

if sy-subrc = 0.

i_contracts5-tdline = text_lines-tdline.

endif.

endif.

i_contracts5-ebeln = i_ekpo-ebeln.

i_contracts5-ebelp = i_ekpo-ebelp.

i_contracts5-tdid = 'K04'.

i_contracts5-i1 = 'Ï'.

i_contracts5-i2 = 'Ï'.

i_contracts5-i3 = 'Ï'.

append i_contracts5.

clear : i_contracts5, h_text, text_lines.

**get standard Texts for K05

CALL FUNCTION 'READ_TEXT'

EXPORTING

ID = 'K05'

LANGUAGE = 'E'

NAME = w_name

OBJECT = 'EKPO'

IMPORTING

HEADER = h_text

TABLES

LINES = text_lines

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 = 0.

read table text_lines index 1.

if sy-subrc = 0.

i_contracts5-tdline = text_lines-tdline.

endif.

endif.

i_contracts5-ebeln = i_ekpo-ebeln.

i_contracts5-ebelp = i_ekpo-ebelp.

i_contracts5-tdid = 'K05'.

i_contracts5-i1 = 'Ï'.

i_contracts5-i2 = 'Ï'.

i_contracts5-i3 = 'Ï'.

append i_contracts5.

clear : i_contracts5, h_text, text_lines.

endloop.

***Populate i_contracts1

loop at i_ekko.

i_contracts1-ebeln = i_ekko-ebeln.

i_contracts1-waers1 = i_ekko-waers.

i_contracts1-waers2 = i_ekko-waers.

if i_ekko-kdatb ne '00000000'.

concatenate i_ekko-kdatb6(2) '/' i_ekko-kdatb4(2) '/'

i_ekko-kdatb(4) into date1.

i_contracts1-date1 = date1.

else.

date1 = ' '.

i_contracts1-date1 = date1.

endif.

if i_ekko-kdate ne '00000000'.

concatenate i_ekko-kdate6(2) '/' i_ekko-kdate4(2) '/'

i_ekko-kdate(4) into date2.

i_contracts1-date2 = date2.

else.

date2 = ' '.

i_contracts1-date2 = date2.

endif.

i_contracts1-ekorg1 = i_ekko-ekorg.

i_contracts1-ekorg2 = i_ekko-ekorg.

i_contracts1-lifnr = i_ekko-lifnr.

i_contracts1-ekgrp = i_ekko-ekgrp.

i_contracts1-zterm = i_ekko-zterm.

i_contracts1-bukrs = i_ekko-bukrs.

i_contracts1-inco1 = i_ekko-inco1.

i_contracts1-inco2 = i_ekko-inco2.

i_contracts1-ktwrt = i_ekko-ktwrt.

i_contracts1-i1 = 'Ï'.

i_contracts1-i2 = 'Ï'.

i_contracts1-i3 = 'Ï'.

i_contracts1-i4 = 'Ï'.

i_contracts1-i5 = 'Ï'.

i_contracts1-i6 = 'Ï'.

i_contracts1-i7 = 'Ï'.

i_contracts1-i8 = 'Ï'.

i_contracts1-i9 = 'Ï'.

i_contracts1-i10 = 'Ï'.

i_contracts1-i11 = 'Ï'.

i_contracts1-i12 = 'Ï'.

i_contracts1-i13 = 'Ï'.

append i_contracts1.

clear i_contracts1.

endloop.

***Populate i_contracts4

loop at i_ekpo.

i_contracts4-ebelp = i_ekpo-ebelp.

read table i_ekko with key ebeln = i_ekpo-ebeln.

if sy-subrc = 0.

i_contracts4-ebeln = i_ekko-ebeln.

read table i_konv with key knumv = i_ekko-knumv.

if sy-subrc = 0.

i_contracts4-kschl = i_konv-kschl.

i_contracts4-kmein = i_konv-kmein.

i_contracts4-waers = i_konv-waers.

i_contracts4-kpein = i_konv-kpein.

i_contracts4-KAWRT = i_konv-KAWRT.

  • MOVE i_konv-KAWRT TO i_contracts4-KAWRT.

endif.

i_contracts4-i1 = 'Ï'.

i_contracts4-i2 = 'Ï'.

i_contracts4-i3 = 'Ï'.

i_contracts4-i4 = 'Ï'.

i_contracts4-i5 = 'Ï'.

i_contracts4-i6 = 'Ï'.

append i_contracts4.

clear i_contracts4.

endif.

endloop.

***Populate i_contracts3

loop at i_ekpa.

i_contracts3-ebeln = i_ekpa-ebeln.

i_contracts3-ebelp = i_ekpa-ebelp.

i_contracts3-parvw = i_ekpa-parvw.

i_contracts3-lifn2 = i_ekpa-lifn2.

i_contracts3-i1 = 'Ï'.

i_contracts3-i2 = 'Ï'.

i_contracts3-i3 = 'Ï'.

append i_contracts3.

clear i_contracts3.

endloop.

ENDFORM. " process_data

*&----


*

FORM download_app_server.

concatenate dataset1 datadrop '_' obj_name '_' '0010' '_'

sy-datum '_' '01' '.DAT' into dataset1.

concatenate dataset2 datadrop '_' obj_name '_' '0020' '_'

sy-datum '_' '01' '.DAT' into dataset2.

concatenate dataset3 datadrop '_' obj_name '_' '0030' '_'

sy-datum '_' '01' '.DAT' into dataset3.

concatenate dataset4 datadrop '_' obj_name '_' '0040' '_'

sy-datum '_' '01' '.DAT' into dataset4.

concatenate dataset5 datadrop '_' obj_name '_' '0050' '_'

sy-datum '_' '01' '.DAT' into dataset5.

*Create First Data Set

perform open_dataset using dataset1.

transfer text-001 to dataset1.

loop at i_contracts1.

transfer i_contracts1 to dataset1.

if i_contracts1-ebeln+0(1) ca '0123456789'.

cnt1 = cnt1 + i_contracts1-ebeln.

endif.

endloop.

perform close_dataset using dataset1.

*Create Second Data Set

perform open_dataset using dataset2.

transfer text-002 to dataset2.

loop at i_contracts2.

transfer i_contracts2 to dataset2.

if i_contracts2-matnr+0(1) ca '0123456789'.

cnt2 = cnt2 + i_contracts2-matnr.

endif.

endloop.

perform close_dataset using dataset2.

*Create Third Data Set

perform open_dataset using dataset3.

transfer text-003 to dataset3.

loop at i_contracts3.

transfer i_contracts3 to dataset3.

if i_contracts3-ebeln+0(1) ca '0123456789'.

cnt3 = cnt3 + i_contracts3-ebeln.

endif.

endloop.

perform close_dataset using dataset3.

*Create Fourth Data Set

perform open_dataset using dataset4.

transfer text-004 to dataset4.

loop at i_contracts4.

transfer i_contracts4 to dataset4.

if i_contracts4-ebeln+0(1) ca '0123456789'.

cnt4 = cnt4 + i_contracts4-ebeln.

endif.

endloop.

perform close_dataset using dataset4.

*Create Fifth Data Set

perform open_dataset using dataset5.

transfer text-005 to dataset5.

loop at i_contracts5.

transfer i_contracts5 to dataset5.

if i_contracts5-ebeln+0(1) ca '0123456789'.

cnt5 = cnt5 + i_contracts5-ebeln.

endif.

endloop.

perform close_dataset using dataset5.

    • Audit & Reconcilation for Rec-id 0010

describe table i_contracts1 lines ln.

zerp_extract_anr-object = 'SCM_C_46'.

zerp_extract_anr-ext_date = sy-datum.

zerp_extract_anr-rec_id = '0010'.

zerp_extract_anr-rec_cnt = ln.

zerp_extract_anr-column_cnt = '14'.

zerp_extract_anr-hash = cnt1.

zerp_extract_anr-column_name = 'EBELN-Purchasing document number'.

modify zerp_extract_anr from zerp_extract_anr.

    • Audit & Reconcilation for Rec-id 0020

describe table i_contracts2 lines ln.

zerp_extract_anr-object = 'SCM_C_46'.

zerp_extract_anr-ext_date = sy-datum.

zerp_extract_anr-rec_id = '0020'.

zerp_extract_anr-rec_cnt = ln.

zerp_extract_anr-column_cnt = '19'.

zerp_extract_anr-hash = cnt2.

zerp_extract_anr-column_name = 'MATNR-Material number'.

modify zerp_extract_anr from zerp_extract_anr.

    • Audit & Reconcilation for Rec-id 0030

describe table i_contracts3 lines ln.

zerp_extract_anr-object = 'SCM_C_46'.

zerp_extract_anr-ext_date = sy-datum.

zerp_extract_anr-rec_id = '0030'.

zerp_extract_anr-rec_cnt = ln.

zerp_extract_anr-column_cnt = '4'.

zerp_extract_anr-hash = cnt3.

zerp_extract_anr-column_name = 'EBELN-Purchasing document number'.

modify zerp_extract_anr from zerp_extract_anr.

    • Audit & Reconcilation for Rec-id 0040

describe table i_contracts4 lines ln.

zerp_extract_anr-object = 'SCM_C_46'.

zerp_extract_anr-ext_date = sy-datum.

zerp_extract_anr-rec_id = '0040'.

zerp_extract_anr-rec_cnt = ln.

zerp_extract_anr-column_cnt = '07'.

zerp_extract_anr-hash = cnt4.

zerp_extract_anr-column_name = 'EBELN-Purchasing document number'.

modify zerp_extract_anr from zerp_extract_anr.

    • Audit & Reconcilation for Rec-id 0050

describe table i_contracts5 lines ln.

zerp_extract_anr-object = 'SCM_C_46'.

zerp_extract_anr-ext_date = sy-datum.

zerp_extract_anr-rec_id = '0050'.

zerp_extract_anr-rec_cnt = ln.

zerp_extract_anr-column_cnt = '04'.

zerp_extract_anr-hash = cnt5.

zerp_extract_anr-column_name = 'EBELN-Purchasing document number'.

modify zerp_extract_anr from zerp_extract_anr.

ENDFORM. " download_app_server

*&----


*

FORM open_dataset USING P_DATASET.

open dataset p_dataset for output in text mode.

if sy-subrc <> 0.

write: / text-e00, sy-subrc.

stop.

endif.

ENDFORM. " open_dataset

*&----


*

FORM close_dataset USING P_DATASET.

close dataset p_dataset.

ENDFORM. " close_dataset

Reaward points if helpful.

Regards.

Srikanta Gope

Former Member
0 Kudos
66

Hi,

Here is the simple example Program

[code]*&---------------------------------------------------------------------*
*& Report  ZUPLOADTAB                                                  *
*&                                                                     *
*&---------------------------------------------------------------------*
*& Example of Uploading tab delimited file                             *
*&                                                                     *
*&---------------------------------------------------------------------*
REPORT  zuploadtab                    .

PARAMETERS: p_infile  LIKE rlgrap-filename
                        OBLIGATORY DEFAULT  '/usr/sap/'..

DATA: ld_file LIKE rlgrap-filename.

*Internal tabe to store upload data
TYPES: BEGIN OF t_record,
    name1 like pa0002-VORNA,
    name2 like pa0002-name2,
    age   type i,
    END OF t_record.
DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,
      wa_record TYPE t_record.

*Text version of data table
TYPES: begin of t_uploadtxt,
  name1(10) type c,
  name2(15) type c,
  age(5)  type c,
 end of t_uploadtxt.
DATA: wa_uploadtxt TYPE t_uploadtxt.

*String value to data in initially.
DATA: wa_string(255) type c.

constants: con_tab TYPE x VALUE '09'.

*If you have Unicode check active in program attributes then you will
*need to declare constants as follows:

*class cl_abap_char_utilities definition load.
*constants:
*    con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB.



************************************************************************
*START-OF-SELECTION
START-OF-SELECTION.
ld_file = p_infile.
OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
ELSE.
  DO.
    CLEAR: wa_string, wa_uploadtxt.
    READ DATASET ld_file INTO wa_string.
    IF sy-subrc NE 0.
      EXIT.
    ELSE.
      SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1
                                      wa_uploadtxt-name2
                                      wa_uploadtxt-age.
      MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.
      APPEND wa_upload TO it_record.
    ENDIF.
  ENDDO.
  CLOSE DATASET ld_file.
ENDIF.


************************************************************************
*END-OF-SELECTION
END-OF-SELECTION.
*!! Text data is now contained within the internal table IT_RECORD

* Display report data for illustration purposes
  loop at it_record into wa_record.
    write:/     sy-vline,
           (10) wa_record-name1, sy-vline,
           (10) wa_record-name2, sy-vline,
           (10) wa_record-age, sy-vline.
  endloop.

[/code]

Regards

Sudheer