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

Problem with export/import in back ground

Former Member
0 Likes
3,568

Hi Experts,

I am having a requirement in which i am exporting an internal table to memory from one program and importing that in another program. in foreground it is working fine. But in background it is not working. Is there any work around.

Here is sample code.


Program1:

types:
  begin of tab_type,
    para type string,
    dobj type string,
  end of tab_type.

data:
  id    type c length 10 value 'TEXTS',
  text1 type string value `IKE`,
  text2 type string value `TINA`,
  line  type tab_type,
  itab  type standard table of tab_type,
    itab1  type standard table of tab_type.

line-para = 'P1'.
line-dobj = 'TEXT1'.
append line to itab.

line-para = 'P2'.
line-dobj = 'TEXT2'.
append line to itab.
free memory id 'TD'.
export itab to memory id 'TD'.


Program2:
types:
  begin of tab_type,
    para type string,
    dobj type string,
  end of tab_type.

data:
  id    type c length 10 value 'TEXTS',
  text1 type string value `IKE`,
  text2 type string value `TINA`,
  line  type tab_type,
  itab  type standard table of tab_type,
    itab1  type standard table of tab_type.
refresh itab.
import itab from memory id 'TD'.
free memory id 'TD'.
clear line.
loop at itab into line.
  write: / line-para, line-dobj.
  clear line.
endloop.

Thanks,

Jyothi

1 ACCEPTED SOLUTION
Read only

former_member203501
Active Contributor
0 Likes
2,033

hi see this ..

and

10 REPLIES 10
Read only

KK07
Contributor
0 Likes
2,033

Hi Jyothi,

which Program You Are Executing in Background,First one or second one?

For Better result use SUBMIT and return before import.

Ex:SUBMIT PROGRAM1 AND RETURN(IN SECOND PROGRAM).

this should work..

Cheers,

KK

Edited by: krishna kishore on Apr 17, 2009 6:42 PM

Read only

Former Member
0 Likes
2,033

Thanks KK..

I missed some lines in the posted code. the issues is i am submitting a program in background, in that i am importing the eported data from memory. but the exported memory is not available inthe background running program.

Is there any way to get the exported memory data in the background job.

Here is the program.

Program1:

types:

begin of tab_type,

para type string,

dobj type string,

end of tab_type.

data:

id type c length 10 value 'TEXTS',

text1 type string value `IKE`,

text2 type string value `TINA`,

line type tab_type,

itab type standard table of tab_type,

itab1 type standard table of tab_type.

line-para = 'P1'.

line-dobj = 'TEXT1'.

append line to itab.

line-para = 'P2'.

line-dobj = 'TEXT2'.

append line to itab.

free memory id 'TD'.

export itab to memory id 'TD'.

DATA: number TYPE tbtcjob-jobcount,

name TYPE tbtcjob-jobname VALUE 'CRDR_ ',

print_parameters TYPE pri_params.

CONCATENATE name

sy-datum

INTO name .

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = name

IMPORTING

jobcount = number

EXCEPTIONS

cant_create_job = 1

invalid_job_data = 2

jobname_missing = 3

OTHERS = 4.

IF sy-subrc = 0.

SUBMIT ZPROGRAM2_BACKGROUND

TO SAP-SPOOL

SPOOL PARAMETERS print_parameters

WITHOUT SPOOL DYNPRO

VIA JOB name NUMBER number

AND RETURN.

IF sy-subrc = 0.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobcount = number

jobname = name

strtimmed = 'X'

EXCEPTIONS

cant_start_immediate = 1

invalid_startdate = 2

jobname_missing = 3

job_close_failed = 4

job_nosteps = 5

job_notex = 6

lock_failed = 7

OTHERS = 8.

ENDIF.

ENDIF.

Program2: ZPROGRAM2_BACKGROUND

types:

begin of tab_type,

para type string,

dobj type string,

end of tab_type.

data:

id type c length 10 value 'TEXTS',

text1 type string value `IKE`,

text2 type string value `TINA`,

line type tab_type,

itab type standard table of tab_type,

itab1 type standard table of tab_type.

refresh itab.

import itab from memory id 'TD'.

free memory id 'TD'.

clear line.

loop at itab into line.

write: / line-para, line-dobj.

clear line.

endloop.

Thanks,

Jyothi

Read only

0 Likes
2,033

Hi Jyothi,

You are not getting any values because, there will be no values.

This is because in the second report you are using import which can have values only when

export is done!!

What i mean to say is submitting the second program(which has no output) in the first program

will not get any output.Insted try reverse that is call the first program in the second program like..

report program2.

types:

begin of tab_type,

para type string,

dobj type string,

end of tab_type.

data:

id type c length 10 value 'TEXTS',

text1 type string value `IKE`,

text2 type string value `TINA`,

line type tab_type,

itab type standard table of tab_type,

itab1 type standard table of tab_type.

refresh itab.

submit program1 and return.

import itab from memory id 'TD'.

free memory id 'TD'.

clear line.

loop at itab into line.

write: / line-para, line-dobj.

clear line.

endloop.

This should work..

Cheers,

KK

Read only

0 Likes
2,033

In a simpler way P1 > exports P2 > imports

you are submitting P2 in Bckd. when P1 did not do its work, how can P2 import it...

solution:>> submit P1 in P2 and then import in P2

P2 progra should look like this:

submit P1 with.....

import memory...'TD'..

Read only

Former Member
0 Likes
2,033

Program 1 fucntionality.

1. Export the values to Memory ID and submits the Program2 in Background.

Program2 functionalidy.

1. Import the valules from memory ID exported and do the process.

But in the background job (program2) the values are not imported.

Any solution...

Thanks,

Jyothi

Read only

Former Member
0 Likes
2,033

HI,

In background Export/Import will not work ..Instead you can try with Export/Import to database.

Refer to this link..

Read only

0 Likes
2,033

hi,

you have written the loop..endloop statement(write) in the second program,

thats you are not able to see the output.. insted it should be in the first report which you are executing..!

Cheers,

KK

Edited by: krishna kishore on Apr 17, 2009 7:53 PM

Read only

former_member203501
Active Contributor
0 Likes
2,034

hi see this ..

and

Read only

0 Likes
2,033

Thanks for your links Venkat.

My problem is solved by using the SHARED BUFFER.

Here is the code i used inthe first program

DATA: wa_invdata(10) TYPE c VALUE 'INVDATA'.

DATA: wa_month(10) TYPE c VALUE 'MONTH'.

DATA: wa_process(10) TYPE c VALUE 'PROCESS'.

EXPORT wa_month_end TO MEMORY ID 'MONTHEND'.

EXPORT e_process = it_inv_data[]

TO SHARED BUFFER indx(st) ID wa_process.

EXPORT e_month = wa_month_end

TO SHARED BUFFER indx(st) ID wa_month.

EXPORT e_invdata = it_tab[]

TO SHARED BUFFER indx(st) ID wa_invdata.

  • EXPORT it_inv_data TO MEMORY ID 'PROCESS'.

DATA: number TYPE tbtcjob-jobcount,

name TYPE tbtcjob-jobname VALUE 'CRDR_ ',

print_parameters TYPE pri_params.

CONCATENATE name

sy-datum

INTO name .

*CALL FUNCTION 'GET_PRINT_PARAMETERS'

  • EXPORTING

  • no_dailog = 'X'

  • archive_mode = '3'

  • IMPORTING

  • out_parameters = print_parameters

  • out_archive_parameters = archi_parameters

  • valid = valid_flag

  • EXCEPTIONS

  • invalid_print_params = 2

  • OTHERS = 4.

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = name

IMPORTING

jobcount = number

EXCEPTIONS

cant_create_job = 1

invalid_job_data = 2

jobname_missing = 3

OTHERS = 4.

IF sy-subrc = 0.

print_parameters-pdest = 'locl'.

SUBMIT zsd_crdr_monthend_back_process

TO SAP-SPOOL

SPOOL PARAMETERS print_parameters

WITHOUT SPOOL DYNPRO

VIA JOB name NUMBER number

AND RETURN.

IF sy-subrc = 0.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobcount = number

jobname = name

strtimmed = 'X'

EXCEPTIONS

cant_start_immediate = 1

invalid_startdate = 2

jobname_missing = 3

job_close_failed = 4

job_nosteps = 5

job_notex = 6

lock_failed = 7

OTHERS = 8.

............................

Second Program

Program zsd_crdr_monthend_back_process.

DATA: wa_invdata(10) TYPE c VALUE 'INVDATA'.

DATA: wa_month(10) TYPE c VALUE 'MONTH'.

DATA: wa_process(10) TYPE c VALUE 'PROCESS'.

*

IMPORT e_invdata = it_tab[]

FROM SHARED BUFFER indx(st) ID wa_invdata.

IF sy-subrc NE 0 OR it_tab[] IS INITIAL..

  • No data found for the Month end processing

MESSAGE s398(00)

WITH 'No Data Found'.

STOP.

ELSE.

  • found the data

IMPORT e_process = it_inv_data[]

FROM SHARED BUFFER indx(st) ID wa_process.

IMPORT e_month = wa_month_end

FROM SHARED BUFFER indx(st) ID wa_month.

Thanks for your help.

Read only

Former Member
0 Likes
2,033

sol 1 ..try EXPORT a1 = b1 DATABASE dbtab(ar) [FROM wa] [CLIENT cl] ID id, (may not work in background)

sol 2...if the second program is a z program and a newly developed one, convert it into a FM so that we can use exporting and importing..