Skip to Content
author's profile photo Former Member
Former Member

Runtime decision for FM ?

How can i make my report decide which method to use for file upload based on : whether it is run in foreground or background at run time ?

I tried using the sy-batch system variable like this :

if sy-batch = 0.

OPEN DATASET fname FOR INPUT IN TEXT MODE ENCODING DEFAULT.

WHILE SY-SUBRC = 0.

READ DATASET fname INTO i_holdT.

IF SY-SUBRC = 0.

append i_holdT TO I_HOLD.

ENDIF.

ENDWHILE.

CLOSE DATASET fname.

else.

call function 'GUI_UPLOAD'

exporting

filename = fname

  • filetype = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • header_length = 0

  • read_by_line = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • replacement = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • IMPORTING

  • FILELENGTH =

  • HEADER =

tables

data_tab = i_hold

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_READ_ERROR = 2

  • NO_BATCH = 3

  • GUI_REFUSE_FILETRANSFER = 4

  • INVALID_TYPE = 5

  • NO_AUTHORITY = 6

  • UNKNOWN_ERROR = 7

  • BAD_DATA_FORMAT = 8

  • HEADER_NOT_ALLOWED = 9

  • SEPARATOR_NOT_ALLOWED = 10

  • HEADER_TOO_LONG = 11

  • UNKNOWN_DP_ERROR = 12

  • ACCESS_DENIED = 13

  • DP_OUT_OF_MEMORY = 14

  • DISK_FULL = 15

  • DP_TIMEOUT = 16

  • OTHERS = 17

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

endif.

But when i debug the code , while running in forground , the sy-batch has nothing in it ...!! and when run it in foreground it throws an exception of " CONV_NO_NUM".

If anyone has sample code or idea how to ahcieve this , pls help !

Thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 26, 2006 at 03:44 PM

    Hi,

    You should check SY-BATCH = 'X' for background..and not SY-BATCH = 0..

    Thanks,

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 26, 2006 at 03:49 PM

    The valid values for Sy-batch are X and space.

    sy-batch = 'X' mean running in background and space means foreground.

    Regards,

    ravi

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.