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

SUBMIT a FIELD SYMBOL as program name

Former Member
0 Likes
2,682

Hi All,

I need some help with field symbols.

I try to submit a dynamic program name but I have problems.

I do a LOOP on a table witch contain a list of program and variant to be submitted by job.

So Y try to assign my program name to a field symbol but it is not assigned.

Please advice.

Thanks.

Here is the code I use :

          DATA l_programme(40) TYPE c.
        FIELD-SYMBOLS: <prog> TYPE program.

        MOVE w_sel_prog-report TO l_programme.
        ASSIGN (l_programme) TO <prog>.   
                
        IF <prog> IS ASSIGNED.
          SUBMIT <prog> TO SAP-SPOOL
                            USING SELECTION-SET w_sel_prog-variant
                            SPOOL PARAMETERS print_parameters
                            WITHOUT SPOOL DYNPRO
                            VIA JOB name NUMBER number
                            AND RETURN.

1 ACCEPTED SOLUTION
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
2,219

A small question why do you need a field symbol in this case you can directly pass the variable name containing program

Hi All,

I need some help with field symbols.

I try to submit a dynamic program name but I have problems.

I do a LOOP on a table witch contain a list of program and variant to be submitted by job.

So Y try to assign my program name to a field symbol but it is not assigned.

Please advice.

Thanks.

Here is the code I use :

          DATA l_programme(40) TYPE c.
        FIELD-SYMBOLS: <prog> TYPE program.

        MOVE w_sel_prog-report TO l_programme.
        ASSIGN (l_programme) TO <prog>.   
                
        IF <prog> IS ASSIGNED.
          SUBMIT <prog> TO SAP-SPOOL
                            USING SELECTION-SET w_sel_prog-variant
                            SPOOL PARAMETERS print_parameters
                            WITHOUT SPOOL DYNPRO
                            VIA JOB name NUMBER number
                            AND RETURN.

13 REPLIES 13
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
2,220

A small question why do you need a field symbol in this case you can directly pass the variable name containing program

Read only

0 Likes
2,219

Hi,

When I pass directly the variable name the program is not find as it try to run the variable name program.


Read only

0 Likes
2,219

Hi Marie

Do as shown below. Put a bracket around variable name then it will take value

DATA:lv_prog TYPE sy-cprog VALUE 'ZTMP_NA2'.

BREAK-POINT.

SUBMIT  (lv_prog)  AND RETURN.

Nabheet

Read only

0 Likes
2,219

Thank you Nabheet

It's ok now

Best regards.

Read only

Abhijit74
Active Contributor
0 Likes
2,219

Hello,

I think you have a problem with Assigning right? So, please check the assign statement .

You declare your field symbol as TYPE ANY .  Or Make both declaration as same.

Thanks & Regards,

Abhijit

Read only

Former Member
0 Likes
2,219

Hello Abhijit,

I try to use a type any but my firld symbol ius not assigned too.

Thanks and regards.

Marie.

Read only

adrian_mejido
Contributor
0 Likes
2,219

Hi Marie,

The problem is in your code, you have to use this code:

DATA l_programme(40) TYPE c.
        FIELD-SYMBOLS: <prog> TYPE any.

        MOVE w_sel_prog-report TO l_programme.
        ASSIGN l_programme TO <prog>.   
                
        IF <prog> IS ASSIGNED.
          SUBMIT <prog> TO SAP-SPOOL
                            USING SELECTION-SET w_sel_prog-variant
                            SPOOL PARAMETERS print_parameters
                            WITHOUT SPOOL DYNPRO
                            VIA JOB name NUMBER number
                            AND RETURN.



When you do the ASSIGN you don't need brackets.



Best Regards

Read only

0 Likes
2,219

Yes either this way or simply put brackets around variable name

Read only

0 Likes
2,219


Hi Adrian,

Here is the code I use now

          DATA l_programme(40) TYPE c.
        FIELD-SYMBOLS: <prog> TYPE any.

        MOVE w_sel_prog-report TO l_programme.
        ASSIGN l_programme TO <prog>.

        IF <prog> IS ASSIGNED.
          SUBMIT <prog> TO SAP-SPOOL
                            USING SELECTION-SET w_sel_prog-variant
                            SPOOL PARAMETERS print_parameters
                            WITHOUT SPOOL DYNPRO
                            VIA JOB name NUMBER number
                            AND RETURN.
          IF sy-subrc = 0.

And when I run my program I have the following dump :

Analyse des erreurs
    On account of a branch in the program
    (CALL FUNCTION/DIALOG, external PERFORM, SUBMIT)
    or a transaction call, another ABAP/4 program
    is to be loaded, namely "<PROG>".

    However, program "<PROG>" does not exist in the library.

    Possible reasons:
    a) Wrong program name specified in an external PERFORM or
       SUBMIT or, when defining a new transaction, a new
       dialog module or a new function module.
    b) Transport error

Thanks and regards

Marie.

Read only

0 Likes
2,219

Hi Marie,

To avoid this dump you should do the submit like this:

SUBMIT (<fs_prog>) .................

But If you notice, you don't need the FIELD-SYMBOL.

You can do this:

      DATA l_programme(40) TYPE c.
    FIELD-SYMBOLS: <prog> TYPE program.

    MOVE w_sel_prog-report TO l_programme.
   
          
      SUBMIT (l_programme) TO SAP-SPOOL        " You can call SUBMIT (w_sel_prog-report)
                        USING SELECTION-SET w_sel_prog-variant
                        SPOOL PARAMETERS print_parameters
                        WITHOUT SPOOL DYNPRO
                        VIA JOB name NUMBER number
                        AND RETURN.

Best regard

Read only

0 Likes
2,219

Thanks a lot for your Help,

It's OK now.

Best regards

Marie.


Read only

0 Likes
2,219

Hi Marie,

I think the conclusion here is that the SUBMIT command does not accept a field-symbol as input.  As others have mentioned (and as seems a viable approach in your code) using varable l_programme in brackets is the necessary approach;

          MOVE w_sel_prog-report TO l_programme.

          SUBMIT  (l_programme) TO SAP-SPOOL

                            USING SELECTION-SET w_sel_prog-variant

                            SPOOL PARAMETERS print_parameters

                            WITHOUT SPOOL DYNPRO

                            VIA JOB name NUMBER number

                            AND RETURN.

Or possibly;

          SUBMIT  (w_sel_prog-report) TO SAP-SPOOL

                            USING SELECTION-SET w_sel_prog-variant

                            SPOOL PARAMETERS print_parameters

                            WITHOUT SPOOL DYNPRO

                            VIA JOB name NUMBER number

                            AND RETURN.

Regards,

Nick

Edit: Started typing this post before the question was closed.  Arrived at the party late, just as everyone else was leaving!

Read only

0 Likes
2,219

Hi Nick,

You can use a FIELD-SYMBOL but you need to put it in brackets.

Despite this fact, the best way in my opinion would be using one of your examples.

Best Regards.