To print by message, I tried to use directly the CALL FUNCTION (WFMC_MESSAGES_SELECT, WFMC_MESSAGES_PROCESS, ...) but it didn't work.
So I'm trying to use the standard program RSNAST0D.
If I call it by SE38, it works fine with my example. If I call by my z-program it doesn't work.
If I stop the program in debug at the first instruction (CALL FUNCTION 'WFMC_MESSAGES_SELECT') in two sessions with both the two cases (called directly by SE38 and called by my z-program) I can see the same parameters values in both sessions.
But only one of them gets the spool.
This is the code of the SUBMIT, but I think it is not important: I'm sure that the parameters values are identical, as it was called directly:
wa_selection-selname = 'S_KAPPL'.
wa_selection-kind = 'S'.
wa_selection-sign = 'I'.
wa_selection-option = 'EQ'.
wa_selection-low = 'V2'.
APPEND wa_selection TO it_selection.
wa_selection-selname = 'S_NACHA'.
wa_selection-kind = 'S'.
wa_selection-sign = 'I'.
wa_selection-option = 'EQ'.
wa_selection-low = '1'.
APPEND wa_selection TO it_selection.
wa_selection-selname = 'S_KSCHL'.
wa_selection-kind = 'S'.
wa_selection-sign = 'I'.
wa_selection-option = 'EQ'.
IF f_type = 'PKL'.
wa_selection-low = 'ZLD2'.
ELSEIF f_type = 'RIR'.
wa_selection-low = 'ZRIR'.
ELSEIF f_type = 'RID'.
wa_selection-low = 'ZRID'.
ELSEIF f_type = 'DDT'.
wa_selection-low = 'ZLDF'.
ENDIF.
APPEND wa_selection TO it_selection.
wa_selection-selname = 'S_OBJKY'.
wa_selection-kind = 'S'.
wa_selection-sign = 'I'.
wa_selection-option = 'EQ'.
wa_selection-low = wa_zmspool-vbeln.
APPEND wa_selection TO it_selection.
wa_selection-selname = 'P_MODE'.
wa_selection-kind = 'P'.
wa_selection-option = 'EQ'.
wa_selection-low = f_vermo.
APPEND wa_selection TO it_selection.
wa_selection-selname = 'P_DIALOG'.
wa_selection-kind = 'P'.
wa_selection-option = 'EQ'.
wa_selection-low = ' '.
APPEND wa_selection TO it_selection.
wa_selection-selname = 'P_GRID'.
wa_selection-kind = 'P'.
wa_selection-option = 'EQ'.
wa_selection-low = ' '.
APPEND wa_selection TO it_selection.
SUBMIT RSNAST0D WITH SELECTION-TABLE it_selection AND RETURN.