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: 

Number Range Problem

Former Member
0 Kudos

I am uploading a file into ztable and i am creating a unique number attach to a file in Ztable using Number Range (SNRO).

I have created 2 work areas ...1 for file data and 1 for unique Number. I having problem uploading unique number to the corresponnding data in Ztable.

It showing me error that work area is not long enogh.  How to deal with this? Attached is my copy of program file.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hello Hemangi,

The error is in the below statement:

APPEND

      wa_nriv to it_ven_table.

The data type of wa_nriv is different from the data type wa_ven_table.

Are you planning to assign a unique number for each record? In that case you have to modify your code little as below.

Move the FM used for generating number inside loop after Convert Fm date as below:

(No need of separate work area for unique number).

open dataset fname in text mode for input encoding default.

  do .

    read dataset fname into wa_ven_table.

    lv_str = cl_abap_char_utilities=>horizontal_tab.

    if sy-subrc = 0.

        split wa_ven_table at lv_str into wa_ven_table-mandt

                                        wa_ven_table-bstnk

                                         lv_date"wa_ven_table-bstdk

                                         wa_ven_table-matnr

                                         wa_ven_table-mtart

                                         wa_ven_table-maktx

                                         wa_ven_table-meins

                                         wa_ven_table-plgtp

                                         wa_ven_table-ort01

                                         wa_ven_table-land1

                                         wa_ven_table-lifnr

                                         wa_ven_table-name1

                                         wa_ven_table-ID.

        call function 'CONVERT_DATE_TO_INTERNAL'

  exporting

    date_external                  = lv_date

*     ACCEPT_INITIAL_DATE            =

importing

   date_internal                  = wa_ven_table-bstdk

*   EXCEPTIONS

*     DATE_EXTERNAL_IS_INVALID       = 1

*     OTHERS                         = 2

          .

      if sy-subrc <> 0.

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

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

      endif.

* Call the FM for generating unique number here and assign it to wa_ven_table-ID.

CALL FUNCTION 'NUMBER_GET_NEXT'

  EXPORTING

    nr_range_nr                   = '01'

    object                        = 'ZDEMO'

*   QUANTITY                      = '1'

*   SUBOBJECT                     = ' '

*   TOYEAR                        = '0000'

*   IGNORE_BUFFER                 = ' '

IMPORTING

   NUMBER                        = NUMBER

*   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

          .

IF sy-subrc <> 0.

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

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

ELSE.

  COMMIT WORK.

  wa_ven_table-ID = number.

ENDIF.

    append      wa_ven_table to it_ven_table.    

    else.

      exit.

    endif.

    clear wa_ven_table.

  enddo.

Hope it helps you!.

Thanks.

8 REPLIES 8

uppu_narayan
Active Participant
0 Kudos

hi hemagi,

    check the domain of that particular field in data dictionary...................definately something wrong with it....

thanks and regards,

narayan

Former Member
0 Kudos

Hello Hemangi,

The error is in the below statement:

APPEND

      wa_nriv to it_ven_table.

The data type of wa_nriv is different from the data type wa_ven_table.

Are you planning to assign a unique number for each record? In that case you have to modify your code little as below.

Move the FM used for generating number inside loop after Convert Fm date as below:

(No need of separate work area for unique number).

open dataset fname in text mode for input encoding default.

  do .

    read dataset fname into wa_ven_table.

    lv_str = cl_abap_char_utilities=>horizontal_tab.

    if sy-subrc = 0.

        split wa_ven_table at lv_str into wa_ven_table-mandt

                                        wa_ven_table-bstnk

                                         lv_date"wa_ven_table-bstdk

                                         wa_ven_table-matnr

                                         wa_ven_table-mtart

                                         wa_ven_table-maktx

                                         wa_ven_table-meins

                                         wa_ven_table-plgtp

                                         wa_ven_table-ort01

                                         wa_ven_table-land1

                                         wa_ven_table-lifnr

                                         wa_ven_table-name1

                                         wa_ven_table-ID.

        call function 'CONVERT_DATE_TO_INTERNAL'

  exporting

    date_external                  = lv_date

*     ACCEPT_INITIAL_DATE            =

importing

   date_internal                  = wa_ven_table-bstdk

*   EXCEPTIONS

*     DATE_EXTERNAL_IS_INVALID       = 1

*     OTHERS                         = 2

          .

      if sy-subrc <> 0.

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

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

      endif.

* Call the FM for generating unique number here and assign it to wa_ven_table-ID.

CALL FUNCTION 'NUMBER_GET_NEXT'

  EXPORTING

    nr_range_nr                   = '01'

    object                        = 'ZDEMO'

*   QUANTITY                      = '1'

*   SUBOBJECT                     = ' '

*   TOYEAR                        = '0000'

*   IGNORE_BUFFER                 = ' '

IMPORTING

   NUMBER                        = NUMBER

*   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

          .

IF sy-subrc <> 0.

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

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

ELSE.

  COMMIT WORK.

  wa_ven_table-ID = number.

ENDIF.

    append      wa_ven_table to it_ven_table.    

    else.

      exit.

    endif.

    clear wa_ven_table.

  enddo.

Hope it helps you!.

Thanks.

0 Kudos

Thanks Jaffer...... its working but the next problem coming is ....its generating number for every record. but i want to create 1 number for 1 uploading file........ means if file has 10 records....that unique number should be in 10 rows of the record and next number for next file.

and 1 more problem is ....while displaying......its repeating colums means i hv 13colums...its showing me 26...

matt
Active Contributor
0 Kudos

Just call the function module every time you need a new number. After that it's just a matter of programming.

0 Kudos

Hi Hemangi,

Check your internal table whether you having duplicate record or not.

0 Kudos

Thanks everyone.....

Former Member
0 Kudos

Hi,

     The code line APPEND wa_nriv to it_ven_table (line number 150) seems to have caused problem. Please check in debug mode if the data is getting into the internal table it_ven_table correctly.

Hope this helps,

~Athreya

arindam_m
Active Contributor
0 Kudos

Hi,

APPEND wa_nriv to it_ven_table.

The above statement cannot work. Put the following:

wa_ven_table-ID = wa_nriv.

append wa_ven_table to it_ven_table.

That should work. The statement 'APPEND wa_nriv to it_ven_table.' is not required.

Cheers,

Arindam