cancel
Showing results for 
Search instead for 
Did you mean: 

How to Pass Dynamic Selection Field in SAP ABAP Submit Statement?

SANDEEP_077
Explorer
0 Kudos
384

I am working on a custom program where I use the SUBMIT statement to call the F.01 transaction. I need to pass a dynamic selection (Profit Center) as a parameter, but I'm facing issues when trying to pass the values.

I’ve tried the following code, which works for standard parameters but not for dynamic selections:

LOOP 
AT s_values INTO DATA(lv_prctr_value).
  CLEAR ls_dynsel.
  ls_dynsel-selname 'PRCTR'.            
  ls_dynsel-kind    'S'.             
  ls_dynsel-sign    'I'.             
  ls_dynsel-option  'EQ'.        
  ls_dynsel-low     lv_prctr_value.  
  APPEND ls_dynsel TO lt_dynsel.
ENDLOOP. 


SUBMIT rfbila00
  WITH sd_ktopl-low lv_ktopl
  WITH sd_bukrs-low lv_bukrs
  WITH bilavers '1000'
  WITH bilaspra lv_spras
  WITH bilbjahr lv_report_year
  WITH b-monate =  s_bilabmon
  WITH bilvjahr lv_compare_year
  WITH v-monate s_bilavmon

  WITH SELECTION-TABLE lt_dynsel
  EXPORTING LIST TO MEMORY
  AND RETURN.

I got this profit center field name using technical properties of the field. But i pass 'PRCTR' the values are not loading in it 

How can I pass multiple Profit Center values in dynamic selections when using the SUBMIT statement?


Any insights or examples on handling dynamic selections with SUBMIT would be greatly appreciated. Thank you!"

Accepted Solutions (0)

Answers (3)

Answers (3)

guido_s
Participant

Hi Sandeep,

is the profit center a parameter of the standard selection of F.01 or is it a free selection parameter?

For a free selection parameter you have to use WITH FREE SELECTIONS:

 

SUBMIT rfbila00 ... 
   VIA SELECTION-SCREEN
   WITH FREE SELECTIONS texpr.

 

See example here.

Sandra_Rossi
Active Contributor

Read the ABAP documentation. For logical databases, use WITH FREE SELECTIONS.

raymond_giuseppi
Active Contributor
0 Kudos

Check online documenttion for WITH FREE SELECTIONS texpr  which contains a sample code to build the texpr structure using FM FREE_SELECTIONS_RANGE_2_EX (FAGLFREESEL, PRCTR)

 

SANDEEP_077
Explorer
0 Kudos

Hi,

I'm trying to execute RFBILA00 with specific profit center (PRCTR) values using WITH FREE SELECTIONS. However, when I run the code, the report executes but includes all profit centers, not just the one(s) I specified.

Here is my code:

DATA trange TYPE rsds_trange,
      trange_line LIKE LINE OF trange,
      trange_frange_t_line LIKE LINE OF trange_line-frange_t,
      trange_frange_t_selopt_t_line LIKE LINE OF trange_frange_t_line-selopt_t,
      texpr TYPE rsds_texpr.

LOOP AT s_values INTO DATA(lv_prctr_value).
trange_line-tablename = 'FAGLFREESEL'.
trange_frange_t_line-fieldname = 'PRCTR'.
trange_frange_t_selopt_t_line-sign = 'I'.
trange_frange_t_selopt_t_line-option = 'EQ'.
trange_frange_t_selopt_t_line-low = lv_prctr_value.
IF lv_prctr_value IS NOT INITIAL.
APPEND trange_frange_t_selopt_t_line TO trange_frange_t_line-selopt_t.
ENDIF.
ENDLOOP.

APPEND trange_frange_t_line TO trange_line-frange_t.
APPEND trange_line TO trange.

CALL FUNCTION 'FREE_SELECTIONS_RANGE_2_EX'
EXPORTING
field_ranges = trange
IMPORTING
EXPRESSIONS = texpr.

SUBMIT rfbila00
WITH sd_ktopl-low = lv_ktopl
WITH sd_bukrs-low = lv_bukrs
WITH bilavers = '1000'
WITH bilaspra = lv_spras
WITH bilbjahr = lv_report_year
WITH B-MONATE = s_bilabmon
WITH bilvjahr = lv_compare_year
WITH V-MONATE = s_bilaVmon
WITH FREE SELECTIONS texpr
EXPORTING LIST TO MEMORY
AND RETURN.

Issue:

When I debug, I can see that teXpr is populated and passed to the SUBMIT statement, but my specified profit center values are not filtering the report. Instead, the report outputs data for all profit centers.

What I’ve Tried:

  1. I confirmed that the values in trange_frange_t_line are correct before calling FREE_SELECTIONS_RANGE_2_EX.
  2. I checked that the table name (FAGLFREESEL) and field name (PRCTR) align with the data structure in the report.

Any insights on why the FREE SELECTIONS aren’t applying the profit center filter correctly? I would greatly appreciate any suggestions on how to correctly format teXpr or troubleshoot further.

Thank you!




SANDEEP_077
Explorer
0 Kudos
hi