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

User-exit

Former Member
0 Likes
653

Hi,

I am woking with CC02 transaction and in the user-exit i need to run a zreport in the background and need to pass a parameter to that, what is the best way to do it.

thanks& Regards.

Syed

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
598

Hi ,

You can export the value to database INDX and import in the program.

Ex:

TABLES INDX.

TYPES: BEGIN OF ITAB3_TYPE,

CONT(4),

END OF ITAB3_TYPE.

DATA: INDXKEY LIKE INDX-SRTFD VALUE 'KEYVALUE',

F1(4), F2 TYPE P,

ITAB3 TYPE STANDARD TABLE OF ITAB3_TYPE WITH NON-

UNIQUE DEFAULT KEY INITIAL SIZE 2,

WA_INDX TYPE INDX.

  • Fill the data fields before CLUSTR

  • before the actual export

INDX-AEDAT = SY-DATUM.

INDX-USERA = SY-UNAME.

  • Export der Daten.

EXPORT F1 FROM F1

F2 FROM F2

ITAB3 FROM ITAB3

TO DATABASE INDX(ST) FROM WA_INDX ID INDXKEY.

Hope this helps.

Message was edited by: Imtiaz Ahmed

6 REPLIES 6
Read only

Former Member
0 Likes
599

Hi ,

You can export the value to database INDX and import in the program.

Ex:

TABLES INDX.

TYPES: BEGIN OF ITAB3_TYPE,

CONT(4),

END OF ITAB3_TYPE.

DATA: INDXKEY LIKE INDX-SRTFD VALUE 'KEYVALUE',

F1(4), F2 TYPE P,

ITAB3 TYPE STANDARD TABLE OF ITAB3_TYPE WITH NON-

UNIQUE DEFAULT KEY INITIAL SIZE 2,

WA_INDX TYPE INDX.

  • Fill the data fields before CLUSTR

  • before the actual export

INDX-AEDAT = SY-DATUM.

INDX-USERA = SY-UNAME.

  • Export der Daten.

EXPORT F1 FROM F1

F2 FROM F2

ITAB3 FROM ITAB3

TO DATABASE INDX(ST) FROM WA_INDX ID INDXKEY.

Hope this helps.

Message was edited by: Imtiaz Ahmed

Read only

Former Member
0 Likes
598

Syed,

See the below code for submiting report in background.

*Submit report as job(i.e. in background)  
data: jobname like tbtcjob-jobname value
                             ' TRANSFER TRANSLATION'.
data: jobcount like tbtcjob-jobcount,
      host like msxxlist-host.
data: begin of starttime.
        include structure tbtcstrt.
data: end of starttime.
data: starttimeimmediate like btch0000-char1.

* Job open 
  call function 'JOB_OPEN'
       exporting
            delanfrep        = ' '
            jobgroup         = ' '
            jobname          = jobname
            sdlstrtdt        = sy-datum
            sdlstrttm        = sy-uzeit
       importing
            jobcount         = jobcount
       exceptions
            cant_create_job  = 01
            invalid_job_data = 02
            jobname_missing  = 03.
  if sy-subrc ne 0.
                                       "error processing
  endif.

* Insert process into job
 SUBMIT zreport and return 
                with p_param1 = 'value'
                with p_param2 = 'value'
                user sy-uname
                via job jobname
                number jobcount.
  if sy-subrc > 0.
                                       "error processing
  endif.

* Close job
  starttime-sdlstrtdt = sy-datum + 1.
  starttime-sdlstrttm = '220000'.
  call function 'JOB_CLOSE'
       exporting
            event_id             = starttime-eventid
            event_param          = starttime-eventparm
            event_periodic       = starttime-periodic
            jobcount             = jobcount
            jobname              = jobname
            laststrtdt           = starttime-laststrtdt
            laststrttm           = starttime-laststrttm
            prddays              = 1
            prdhours             = 0
            prdmins              = 0
            prdmonths            = 0
            prdweeks             = 0
            sdlstrtdt            = starttime-sdlstrtdt
            sdlstrttm            = starttime-sdlstrttm
            strtimmed            = starttimeimmediate
            targetsystem         = host
       exceptions
            cant_start_immediate = 01
            invalid_startdate    = 02
            jobname_missing      = 03
            job_close_failed     = 04
            job_nosteps          = 05
            job_notex            = 06
            lock_failed          = 07
            others               = 99.
  if sy-subrc eq 0.
                                       "error processing
  endif.

I have a report which sents emails in background(http://www.sap-img.com/abap/sending-mail-with-attachment-report-in-background.htm).

I believe similar way you could <b>SUBMIT</b> a report in background from your user exit.

Hope this helps you.

~thomas.

Read only

Former Member
0 Likes
598

you can pass to the selection screen parameters and select-options as well.

loop at itab.

r_matnr-low = itab-matnr.

append r_matnr.

clear r_matnr.

endloop.

submit zrept with s_matnr in r_matnr.

Regards,

Ravi

Read only

0 Likes
598

Hi,

Yes you could do it the way mentioned in above post or else You could create a event periodic job in SM36 and raise the event from user exit using the Function module <b>BP_EVENT_RAISE</b>. This will trigger the job with your program, you can import the parameter exported from user exit in your program.

Hope this helps.

Read only

Former Member
0 Likes
598

Hi,

If i have to call a transaction in the user-exit and run that in the background.

Thanks& Regards

Syed

Read only

0 Likes
598

Hi,

If it is a report transaction then you can capture the report name from Se93 and do it the same way as mentioned in previous posts. But i'm afraid you will not be able to execute a transaction in background.

Hope this helps.