Application Development and Automation 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: 
Read only

Data transfer to application server - URGENT

Former Member
0 Likes
1,150

Hi,

I have a requirement that, i need to transfer the data from database to a file in Application server. That i can do with Open dataset statement.

At first run of the program, all the data must be transferred to a file with date extension as filename and store at application server.

and from next run onwards, only the new data(different from the first run) in the database must be transferred to a new file with run date extension as file name in application server, if there is no new data available, then no transfer of data.

Can anyone pls. tell me the logic to implement this.

*Points will be awarded.

thanks,

Alankaar.

Hi,

I have a requirement that, i need to transfer the data from database to a file in Application server. That i can do with Open dataset statement.

At first run of the program, all the data must be transferred to a file with date extension as filename and store at application server.

and from next run onwards, only the new data(different from the first run) in the database must be transferred to a new file with run date extension as file name in application server, if there is no new data available, then no transfer of data.

Can anyone pls. tell me the logic to implement this.

*Points will be awarded.

thanks,

Alankaar.

9 REPLIES 9
Read only

Former Member
0 Likes
1,104

Hi,

Can you post your code here. It will helps to find the problem.

Thanks.

Read only

Former Member
0 Likes
1,104

Hi

U should check if your tables are managed by change document, if it's so you cna transfer the new values from them (CDHDR and CDPOS tables).

Max

Read only

Former Member
0 Likes
1,104

Hi Revanth..

As u know the file name that has date in it..

Use OPEN DATASET file.....

now read the content of that file into an internal table.

Compare the new file with this itab data...

using <b>WS_QUERY</b>FM...

this will pass the comparision command in DOS Prompt like..<b>fc file1 file2</b>

if both are same....

don't store the file

..else

store data.

Read only

Former Member
0 Likes
1,104

HI revanth,

Check if your table has a Creation date field.

If there is one, you can select the records that fall in the range of last run date-current date. Get the last run date from the file creation date of the last file.

Regards,

Ravi

Read only

Former Member
0 Likes
1,104

Hi,

Thanks for the responses.

I am selecting the data from different tables and putting them in one final internal table. Then iam passing the internal table values to the file and transferrring them to the application server file.

I am giving the code which i have written.

****getting the data

SELECT plvar

otype

objid

begda

endda

FROM hrp1000 INTO TABLE it_jobcode

WHERE plvar = p_plvar1

AND otype = p_otype1

AND endda = p_endda3.

IF sy-subrc = 0.

SORT it_jobcode BY objid.

ENDIF.

********building final internal table

Loop at it_jobcode.

it_roledownload-jobcode = it_jobcode-objid.

g_fcode = it_jobcode-objid+0(2).

select familycode

rolename

description

from zjobrole into it_jobroledata

up to 1 rows

where familycode = g_fcode.

endselect.

it_roledownload-rolename = it_jobroledata-rolename..

it_roledownload-description = it_jobroledata-description.

it_roledownload-domain_val = 'Varian'.

append it_roledownload.

clear: it_jobcode,

it_jobroledata,

it_roledownload,

g_fcode.

endloop.

********code for data transfer

open dataset p_file4 for output in text mode.

if sy-subrc <> 0.

MESSAGE e013 WITH p_file4.

exit.

endif.

loop at it_roledownload.

g_jobrolefile+0(8) = it_roledownload-jobcode.

g_jobrolefile+8(1) = g_fill. " '|'

g_jobrolefile+9(40) = it_roledownload-rolename.

g_jobrolefile+49(1) = g_fill.

g_jobrolefile+50(50) = it_roledownload-description.

g_jobrolefile+100(1) = g_fill.

g_jobrolefile+101(25) = it_roledownload-domain_val.

transfer g_jobrolefile to p_file4.

endloop.

close dataset p_file4.

please suggest the logic for the problem.

thanks,

Alankaar.

Read only

0 Likes
1,104

Modify your code as follows:

<b>v_date = <last run date + 1>.

r_date-low = v_date.

r_date-high = sy-datum.

r_date-sign = 'I'.

r_date-option = 'EQ'.

append r_date.

clear r_date.</b>

SELECT plvar

otype

objid

begda

endda

FROM hrp1000 INTO TABLE it_jobcode

WHERE plvar = p_plvar1

AND otype = p_otype1

AND endda = p_endda3

<b>and aedtm in r_date.</b>

Regards,

Ravi

Read only

Former Member
0 Likes
1,104

Hi,

You can use TVARV table to updade last run date then u can give the date comparision then u can get new data. And u should give the file name with extention of current date(means concatinate sy-datum with your file name). I hope it will work. if it is useful information dont forget to give the points

Read only

Former Member
0 Likes
1,104

&----


*& Report <name>

*&

&----


*&

*&

&----


REPORT name.

DATA:

BEGIN OF FS_SPFLI,

CARRID TYPE SPFLI-CARRID,

CONNID TYPE SPFLI-CONNID,

COUNTRYFR TYPE SPFLI-COUNTRYFR,

CITYFROM TYPE SPFLI-CITYFROM,

AIRPFROM TYPE SPFLI-AIRPFROM,

COUNTRYTO TYPE SPFLI-COUNTRYTO,

CITYTO TYPE SPFLI-CITYTO,

AIRPTO TYPE SPFLI-AIRPTO,

FLTIME TYPE SPFLI-FLTIME,

DEPTIME TYPE SPFLI-DEPTIME,

ARRTIME TYPE SPFLI-ARRTIME,

DISTANCE TYPE SPFLI-DISTANCE,

DISTID TYPE SPFLI-DISTID,

FLTYPE TYPE SPFLI-FLTYPE,

PERIOD TYPE SPFLI-PERIOD,

END OF FS_SPFLI.

DATA:

T_SPFLI LIKE

STANDARD TABLE

OF FS_SPFLI.

DATA:

BEGIN OF FS_TABLE,

CHAR(100) TYPE C,

END OF FS_TABLE.

DATA:

T_TABLE LIKE

STANDARD TABLE

OF FS_TABLE.

DATA:

BEGIN OF FS_TABLE1,

CHAR(100) TYPE C,

END OF FS_TABLE1.

DATA:

T_TABLE1 LIKE

STANDARD TABLE

OF FS_TABLE1.

SELECT CARRID

CONNID

COUNTRYFR

CITYFROM

AIRPFROM

COUNTRYTO

CITYTO

AIRPTO

FLTIME

DEPTIME

ARRTIME

DISTANCE

DISTID

FLTYPE

PERIOD

FROM SPFLI

INTO TABLE T_SPFLI.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = 'd:\files\p_spfli04'

FILETYPE = 'ASC'

  • APPEND = ' '

  • WRITE_FIELD_SEPARATOR = ' '

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • CONFIRM_OVERWRITE = ' '

  • NO_AUTH_CHECK = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = ' '

  • TRUNC_TRAILING_BLANKS_EOL = 'X'

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = T_SPFLI

  • 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.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'd:\files\p_spfli04'

FILETYPE = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = T_TABLE

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

*LOOP AT T_TABLE INTO FS_TABLE.

  • WRITE:

  • / FS_TABLE-CHAR.

*ENDLOOP.

OPEN DATASET 'p_spfli04' FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF SY-SUBRC EQ 0.

MESSAGE 'File Already Exists' TYPE 'I'.

STOP.

ELSE.

CLOSE DATASET 'p_spfli04'.

ENDIF.

OPEN DATASET 'P_SPFLI02' FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT T_TABLE INTO FS_TABLE.

TRANSFER FS_TABLE TO 'p_spfli04'.

ENDLOOP.

CLOSE DATASET 'p_spfli04'.

*ENDIF.

OPEN DATASET 'p_spfli04' FOR INPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT T_TABLE INTO FS_TABLE.

READ DATASET 'p_spfli04' INTO FS_TABLE.

APPEND FS_TABLE-CHAR TO T_TABLE1.

ENDLOOP.

******************************************************

Here is the sample code to download and upload the file onto presentation server and then using OPEN DATASET you'll be able to transfer the data to APPLICATION SERVER....

Regards,

Pavan P.

Read only

Former Member
0 Likes
1,104

Thanks for the responses,

It is a background schedule job. It must run once in a day, say 10AM.

So it will run with variants.

Please suggest based on this issue.

Ravi,

does your code help when this program scheduled in background job?

thanks