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

module pool - to save number range

Former Member
0 Likes
1,692

hi all,

when i save the entry one number is generated through number range object, but if i press again save, next number is generated, this happens every time i save the entry. how to avoid this?

Thanks

1 ACCEPTED SOLUTION
Read only

GauthamV
Active Contributor
0 Likes
1,550

you might have used that function module during save ,change accordingly in

your program.

12 REPLIES 12
Read only

GauthamV
Active Contributor
0 Likes
1,551

you might have used that function module during save ,change accordingly in

your program.

Read only

Former Member
0 Likes
1,550

Hi,

After the record is saved then either exit the program or go to the initial screen.

regards,

Santosh Thorat

Read only

Former Member
0 Likes
1,550

Hi Khushi,

we have one option in the module pool

PROCESS AFTER INPUT.

MODULE check_change ON CHAIN-REQUEST.

MODULE check_change INPUT.

gv_flag = c_y. "'Y'.

ENDMODULE. " check_change INPUT

IF the gv_flag = 'Y'.

generate your number logic.

ELSE.

not to generate number logic.

ENDIF.

so when ever you chaged in the screen it will generates the number

hope it will solves your problem.

Thanks

Read only

Former Member
0 Likes
1,550

hi,

i have written the foll. code, i have to add more than 1 entry in itab , after adding all the entry i save it , but when i add 1st entry and press enter it goes to screen 1001 ie initial screen,

when 'SAVE'.

move itab-reldt+4(2) to sub.

MOVE ITAB-RELDT+0(4) TO YEAR.

SELECT SINGLE * FROM NRIV INTO ZNRIV WHERE OBJECT = 'ZABC'

AND SUBOBJECT = SUB AND TOYEAR = YEAR.

call function 'NUMBER_RANGE_ENQUEUE'

exporting

object = 'ZABC' "Create with SNUM

exceptions

foreign_lock = 1

object_not_found = 2

system_failure = 3

others = 4.

  • if sy-subrc ne 0.

  • message e086 with 'Lock error' sy-subrc.

  • endif.

CALL FUNCTION 'NUMBER_GET_NEXT'

EXPORTING

nr_range_nr = ZNRIV-NRRANGENR

object = 'ZABC'

IGNORE_BUFFER = 'X'

SUBOBJECT = SUB

TOYEAR = YEAR

IMPORTING

NUMBER = NUM.

.

LOOP AT ITAB.

MOVE NUM TO ITAB-CODE.

MODIFY ITAB.

message W012(zdes) with ITAB-CODE.

insert ZDESIGN FROM TABLE ITAB.

CLEAR OK_CODE.

clear itab.

*clear zdesign.

ENDLOOP.

call function 'NUMBER_RANGE_DEQUEUE'

exporting

object = 'ZABC'.

*WHEN 'MODI'.

SET SCREEN 1001.

Read only

0 Likes
1,550

Hi,

initial screen is displayed but after pressing enter and if we press again save it generated next number

Read only

0 Likes
1,550

hI,

Any one know the solution,

thanx.

Read only

0 Likes
1,550

Only call the code to generate a new number and update the number range if the reference number field on your record is empty.......or use a flag as suggested by one of the posts above.

Read only

Former Member
0 Likes
1,550

Please explain the scenari exactly. What are you running- is it a report?

Check if the field you mention is auto incrementing through the program's lines of codes.

For infotypes, we have a field called SEQNR which populates sequentially when required.

Read only

Former Member
0 Likes
1,550

Please explain the scenari exactly. What are you running- is it a report?

Check if the field you mention is auto incrementing through the program's lines of codes.

For infotypes, we have a field called SEQNR which populates sequentially when required.

Read only

Former Member
0 Likes
1,550

Hi,

Avoid the function module call in your change/update data code and leave it to be used only for create option.

Regards,

Ameet

Read only

Former Member
0 Likes
1,550

Hi,

you can create one flag say

data: g_saved(1) type c.

and in PAI ,in the user command at 'SAVE' ,just check this.

when sy-ucomm = 'SAVE'.
   if g_saved is initial.
       <your process of generating number>
       set the flag ....
       g_saved = 'X'.  " so now if again it is prssed it will not generate it again
  endif.

Regards,

Neha

Read only

Former Member
0 Likes
1,550

THANKS