cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP ALV REPORT in background.

0 Kudos

Hello Expers.

With respect i would like to ask for help/suggestions on this issue.

I have one ALV report and on its selection screen i have maintained some parameters say p1 and p2 for user input and both the parameters are assigned f4 help ( under at selection screen on value help request ) . once user selects the value , i do some calculations on that values and set one flag ( this flag is declared in include top of the report and acts as global)

So post filling the values user have two option to get the output one is by pressing f8 (simple foreground execution ) other is f9 back ground scheduling .

Issue comes the moment user selects f9 (opts for back job ) the value of the flag gets washed.to see it i have done jdbg of scheduled batch.

Could any1 be able to suggest on this.

Additional info.

When i debug backjob it starts from start of selection event.

And the value of flag is getting filled in at selection screen on value help .

Many thanks.

Best Regards .

Accepted Solutions (0)

Answers (4)

Answers (4)

Jelena
Active Contributor

Obviously you can't do it for a report that is designed to run in background. (Not sure it's a good practice in general.)

Why do you have to set this flag on the selection screen? Why can't the same logic be performed later in the program? I'm rather confused by this design choice. You might want to elaborate and/or post a code sample.

Sandra_Rossi
Active Contributor

You may pass the value either via database, or define an extra parameter (possibly using a string-type one SUBMIT WITH <string-type> = serialized data).

0 Kudos

Dear Nic,

Many thanks for your valuable suggestion. But export import is not working in background.

The moment i am importing the values in background its not giving any value.

Best Rega

NTeunckens
Active Contributor
0 Kudos

Hello

As you pointed out, the user needs to use the Value-Help in order to have the value calculated ... So that 'flow' was what I'm emulating.

In my Demo, the user has to Perform a Value-Request ('F4') on the SelScreen-parameter (even though it is a Flag here because of Demo) ... When proceeding via Background ('F9') this should result in the IMPORT / EXPORT with the 'calculated' value ...

Obviously, when just ticking the box, without using the 'F4' Value-request, the IMPORT'ing part is not executed when proceeding in Background mode ...

I thought that was your requirement. Anyhow, this solution should work.

Kind regards

Nic T.

NTeunckens
Active Contributor
0 Kudos

You could look into the use of "SHARED MEMORY" to IMPORT / EXPORT your calculated value, then Fetch it in Background-mode ('SY-BATCH' or 'SY-BINPT' in your 'START-OF-SELECTION' ...

See below sample for a small demo :

REPORT ztmp_demo.
DATA gv_value TYPE char2.

PARAMETERS:
  p_1 TYPE flag.

INITIALIZATION.
  CLEAR: gv_value, p_1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_1.
  "'CALCULATES' YOUR VALUE - FOR DEMO IS SET TO '01'
  PERFORM set_value CHANGING gv_value.

START-OF-SELECTION.
  PERFORM fetch_value_mem CHANGING gv_value.

END-OF-SELECTION.
  WRITE / `Value found : ` && gv_value.

FORM set_value CHANGING value TYPE char2.
  DATA local_value TYPE char2.

  "DEMO SET LOCAL_VALUE TO '01'
  local_value = '01'.

  "EXPORT FOR BACKGROUND PROCESSING
  EXPORT local_value TO SHARED MEMORY indx(st) ID 'ZVAL'.

  "REGULAR FOREGROUND
  value = local_value.

ENDFORM.

FORM fetch_value_mem CHANGING value TYPE char2.

  "WHEN BACKGROUND, READ SHARED MEMORY ...
  CHECK sy-batch = abap_true OR
        sy-binpt = abap_true.
  IMPORT local_value = value FROM SHARED MEMORY indx(st) ID 'ZVAL'.
  DELETE FROM SHARED MEMORY indx(st) ID 'ZVAL'.

ENDFORM.

I don't know if there are better approaches, but this works ... A regular "IMPORT / EXPORT ... TO MEMORY ID" will not work in this case.

Kind regards

Nic T.