11-02-2007 6:40 AM
Hi,
I have created a z-table where ref_number is the key field. I want to fill this table automatically by system so that whenever a new record by customer is entererd, this ref_number will be given to them with response.
So Could any one help me out,
Gud points will be rewar5ded for useful answers.
Thanks in advance,
Sunil
11-02-2007 6:53 AM
hi,
make use of function module:
NUMBER_GET_NEXT
before this you need to define number range for the reference no. for this
goto tcode: snro there create one object and specify number range.
then pass this info to Function Module. and collect it in one variable and then insert in your ztable.
11-02-2007 7:04 AM
Hi Sonali,
Thanks for your kind reply, Could you please elaborate the solution with codes so that I can use it for my program.
Thanks,
Sunil
11-02-2007 7:13 AM
hi,
Number range generation:
tcode: snro.
object : ZFI_RCPT -> create.
specify no. length domain i.e any data element e.g belnr for 10-digit no.
warning % : 1
main memory buffer : yes
no. of number : 10.
once object is crated specify number range:
by entering object in snro and then clicking above on number range tab.
here specify:
no from number to number
01 2000000000 299999999
now goto program:
there call FM
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = '01'
object = 'ZFI_RCPT'
QUANTITY = '1'
SUBOBJECT = ' '
TOYEAR = '0000'
IGNORE_BUFFER = ' '
IMPORTING
number = zft_receipt-docno " specify ur wa field
QUANTITY =
RETURNCODE =
EXCEPTIONS
interval_not_found = 1
number_range_not_intern = 2
object_not_found = 3
quantity_is_0 = 4
quantity_is_not_1 = 5
interval_overflow = 6
buffer_overflow = 7
OTHERS = 8
11-02-2007 7:27 AM
Hi Sonali,
Thanks for you kind reply, but I am not able to get the System generated REQ_NUM and fill the table with the same. The program is as follows,
Could you help me out,
INCLUDE MZFIRSTPAGETOP . " global Data
TABLES: ZCHP_CUST_INFO.
*DATA: OKCODE LIKE SY-UCOMM.
DATA: CNAME LIKE ZCHP_CUST_INFO-CREATED_BY,
REQTYP LIKE ZCHP_CUST_INFO-REQUEST_TYPE,
DESC LIKE ZCHP_CUST_INFO-SHORT_TEXT,
PRIO_TYPE LIKE ZCHP_CUST_INFO-PRIORITY_TYPE,
EFFECTIVE_DATE like ZCHP_CUST_INFO-REQUIRED_STR_DAT,
COMM_TYP like ZCHP_CUST_INFO-MODE_OF_COMM,
COMM like ZCHP_CUST_INFO-ADDRESS,
REF_NUM LIKE ZCHP_CUST_INFO-REQ_NUM.
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'FOR1000'.
SET TITLEBAR '1000'.
ENDMODULE. " STATUS_0100 OUTPUT
INCLUDE MZFIRSTPAGEO01 . " PBO-Modules *
INCLUDE MZFIRSTPAGEI01 . " PAI-Modules *
INCLUDE MZFIRSTPAGEF01 . " FORM-Routines *
&----
*& Module USER_COMMAND_1000 INPUT
&----
text
----
MODULE USER_COMMAND_1000 INPUT.
CASE SY-UCOMM.
WHEN 'SUBMIT'.
ZCHP_CUST_INFO-CREATED_BY = CNAME.
ZCHP_CUST_INFO-REQUEST_TYPE = REQTYP.
ZCHP_CUST_INFO-PRIORITY_TYPE = PRIO_TYPE.
ZCHP_CUST_INFO-SHORT_TEXT = DESC.
ZCHP_CUST_INFO-CREATED_ON = EFFECTIVE_DATE.
ZCHP_CUST_INFO-MODE_OF_COMM = COMM_TYP.
ZCHP_CUST_INFO-ADDRESS = COMM.
INSERT ZCHP_CUST_INFO.
COMMIT WORK.
*----
*GENERATING A REF_NUMBER.
*----
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = '01'
object = 'ZCHP_CUST_INFO'
QUANTITY = '1'
SUBOBJECT = ' '
TOYEAR = '0000'
IGNORE_BUFFER = ' '
IMPORTING
number = ZCHP_CUST_INFO-REQ_NUM " specify ur wa field
QUANTITY =
RETURNCODE =
EXCEPTIONS
interval_not_found = 1
number_range_not_intern = 2
object_not_found = 3
quantity_is_0 = 4
quantity_is_not_1 = 5
interval_overflow = 6
buffer_overflow = 7
OTHERS = 8.
*----
WHEN 'RESET'.
CLEAR: CNAME,REQTYP,PRIO_TYPE,
DESC,EFFECTIVE_DATE,COMM_TYP,COMM.
WHEN 'CANCEL'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_1000 INPUT
Thanks in advance,
Sunil K Shetty
11-02-2007 7:46 AM
hi,
declare :
data: REF_NUM type ZCHP_CUST_INFO-REQ_NUM.
case: sy-ucomm.
when submit.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = '01'
object = 'ZCHP_CUST_INFO'
QUANTITY = '1'
SUBOBJECT = ' '
TOYEAR = '0000'
IGNORE_BUFFER = ' '
IMPORTING
number = REQ_NUM " specify ur wa field
QUANTITY =
RETURNCODE =
EXCEPTIONS
interval_not_found = 1
number_range_not_intern = 2
object_not_found = 3
quantity_is_0 = 4
quantity_is_not_1 = 5
interval_overflow = 6
buffer_overflow = 7
OTHERS = 8.
ZCHP_CUST_INFO-REQ_NUM = REQ_NUM .
ZCHP_CUST_INFO-CREATED_BY = CNAME.
ZCHP_CUST_INFO-REQUEST_TYPE = REQTYP.
ZCHP_CUST_INFO-PRIORITY_TYPE = PRIO_TYPE.
ZCHP_CUST_INFO-SHORT_TEXT = DESC.
ZCHP_CUST_INFO-CREATED_ON = EFFECTIVE_DATE.
ZCHP_CUST_INFO-MODE_OF_COMM = COMM_TYP.
ZCHP_CUST_INFO-ADDRESS = COMM.
INSERT ZCHP_CUST_INFO.
COMMIT WORK.
first generate the no. then take it is structure and then insert.
11-02-2007 9:21 AM
Hi Sonali,
I tried with the same code, but its giving dump error,
" Type conflict when calling a function module"
could you please help on this.
regards,
Sunil
11-02-2007 7:03 AM
Hi
In you table maintenance generator, write code using events in table maintenance screen,
write the below
05 NEW_ENTRY click on the nest column and write the code
when creating new entry pass counter with automatic generation value.
DESCRIBE TABLE total LINES lv_lines.
lv_lines = lv_lines + 1.
zsd-counter = lv_lines.
Regards
Shiva