Application Development 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: 

Seqence number in an outbound file

Former Member
0 Kudos

Hi experts

I would like to send a sequence number in a file name and use the code below.

DATA: bla, bla, bla

selection-screen begin of block blk1 with frame title text-001.

parameters: P_FILE type string obligatory lower case.

selection-screen end of block blk1.

CALL FUNCTION 'NUMBER_GET_NEXT_SOP'

EXEPTION

nrrangenr = NUMBERRANGENUMBER

object = 'ZHR_SEQNR'

quantity = '1'

mandt = SY-MANDT

IMPORTING

number = ZSEQNR

CONCATENATE '/usr/sap/' zseqnr '_' sy-datum '.txt' into p_file.

select * from ..............

The parameters should look like /usr/sap/0000000001_20100511.txt but it looks like this /usr/sap/_20100511.txt

If i call the function modul above, further down, after i have done all the selections i get the sequence number but then it is to late, the parameter has already been set.

Anyone having any idea // Peter B

1 ACCEPTED SOLUTION

SimoneMilesi
Active Contributor
0 Kudos

Hi, try this

selection-screen begin of block blk1 with frame title text-001.
parameters: P_FILE type string obligatory lower case.
selection-screen end of block blk1.

INITIALIZATION. "You should put this piece of code at initialization event
CALL FUNCTION 'NUMBER_GET_NEXT_SOP'
EXEPTION
nrrangenr = NUMBERRANGENUMBER
object = 'ZHR_SEQNR'
quantity = '1'
mandt = SY-MANDT
IMPORTING
number = ZSEQNR

CONCATENATE '/usr/sap/' zseqnr '_' sy-datum '.txt' into p_file.

START-OF-SELECTION. "THe selection must be under START-OF-SELECTION event
Select *.....

ATTENTION! If you don't lock the paramter p_file, the user can change it.

11 REPLIES 11

SimoneMilesi
Active Contributor
0 Kudos

Hi, try this

selection-screen begin of block blk1 with frame title text-001.
parameters: P_FILE type string obligatory lower case.
selection-screen end of block blk1.

INITIALIZATION. "You should put this piece of code at initialization event
CALL FUNCTION 'NUMBER_GET_NEXT_SOP'
EXEPTION
nrrangenr = NUMBERRANGENUMBER
object = 'ZHR_SEQNR'
quantity = '1'
mandt = SY-MANDT
IMPORTING
number = ZSEQNR

CONCATENATE '/usr/sap/' zseqnr '_' sy-datum '.txt' into p_file.

START-OF-SELECTION. "THe selection must be under START-OF-SELECTION event
Select *.....

ATTENTION! If you don't lock the paramter p_file, the user can change it.

0 Kudos

Unfortunately, that did not help.

Any other suggestions?

// Peter B

0 Kudos

ZSEQNR is declared as CHAR or NUMC?

0 Kudos

ZSEQNR is declared as CHAR10

The function module works perfect if it's placed further down in the program.

// Peter B

0 Kudos

Can you put a break point after INITIALIZATION and check if p_file is compiled in the right way, with the seq. number?

0 Kudos

Hi,

If you execute the function module independently in SE37, are you getting the desired output ?

Regards

Vinod

0 Kudos

Hi.

I have executed the FM in SE37 and there it works fine.

I have also put a break after the initialization in the program and had a look, but no sequence number is created.

// Peter B

0 Kudos

Hi,

Check inside the program where you have defined the value for parameter "NUMBERRANGENUMBER" ?

Regards

Vinod

0 Kudos

Data: zhr_seqnr like inri-object,

numberrangenumber like inri-nrrangenr.

numberrangenumber = '01'.

These are defined before the selection-screen.

// Peter B

0 Kudos

Hi,

I simulated your code with some changes & working properly

selection-screen begin of block blk1 with frame title text-001.
parameters: p_file type char256 obligatory lower case.
selection-screen end of block blk1.

data zseqnr(10) type n.
initialization. "You should put this piece of code at initialization event
  call function 'NUMBER_GET_NEXT_SOP'
    exporting
      nr_range_nr = '01'
      object      = 'ZTEST'              
      quantity    = '1'
      mandt       = sy-mandt
    importing
      number      = zseqnr.
  concatenate '/usr/sap/' zseqnr '_' sy-datum '.txt'    into   p_file.

start-of-selection.
  write 😕 p_file.

Regards

Vinod

0 Kudos

Thank you very much Vinod.

I hardcoded nr_range_nr (01) and now it works fine.

// Peter B