SECUENTIAL FIELD IN ZTABLE

Hi,
i´m developing a ZTABLE. In this ztable there are two key fields. One of them (
ZNUMDE) must be the result of concatenating sy-uname(3) sy-datum+2(2) and a secuential
number of 2 digits the moment the entry is created.
This key field must distinguish the number of entries in the table by user.
e.g. user PETER has 2 entries -> 1st ZNUMDE = PET0501
2nd ZNUMDE = PET0502
for user JOHN (1 entry) -> ZNUMDE = JOH0501.
In order to achieve this i´ve created a maintenance view of the table and within the event '01' BEFORE SAVING IN THE DATABASE i´ve created a routine within which i´ve added the following code:  DATA: v_max(2)   TYPE i,
        v_numde(7) TYPE c,
        v_conta(2) TYPE c.
  CLEAR: v_max, v_numde, v_conta.
Here i check the number of entries of a the user
  SELECT COUNT( DISTINCT usuar ) INTO v_max
    FROM ZTABLE WHERE usuar = sy-uname.
  IF v_max GT 0.
    v_max = v_max + 1.
    v_conta = v_max.
  ELSE.
    v_max = 1.
    v_conta = v_max.
  ENDIF.
  SHIFT v_conta RIGHT.
  REPLACE '' WITH '0' INTO v_conta.
  CONCATENATE sy-uname(3) sy-datum+2(2) v_conta
    INTO z_v_devolucion-numde.
  z_v_devolucion-usuar = sy-uname.
The question is that thus i´m not able to get ZDEVNUM as desired.
Any suggestion?
Best regards.

Hi!
It would be easier, if you had described your current (wrong) result.
But my guess is, your not counting existing entries correctly.
Your key znumde has three parts: user, year and counter. In your select, you define just user, but not year.
But when you have already second field usuar (why not user?) for user-id, why not split your key into three separate fields? This would make your selection easier:
select count( * ) into v_max
  from ztable
  where user = sy-uname
   and  year = sy-datum+2(2)
   and  (other key except counter).
By the way: you create a year 2100-problem!
Use v_max type i instead of v_max(2).
with v_conta(2) type n you might get correct format without additional conversion. Otherwise FM CONVERSION_EXIT_ALPHA_INPUT will do the job, too.
Or do you struggle with the event?
Regards,
Christian

Similar Messages

  • Secuential field

    Hi experts!
    I'm making a new Z table and I need a secuential field in it. Do u know if is there any kind of element in SAP to define a field as auto secuential?
    It would be somtething like this:
    1
    2
    3
    4
    5
    6
    7
    Or I have to calculate the value of the field when I want to insert a register?.
    Thanks.

    Hi Jorge,
    You can use the number ranges for the field for which you want to have a sequential number range. But remember you will have to ensure while inserting records in this table, you actually should use the function Module 'NUMBER_GET_NEXT'.
    The transaction where you need to create a number range object is SNRO. Here you create a number range object refering to the dataelement and then you can define number range values as well. And while populating this table all that you need to do is call the number_get_next function module to get the next sequential number and pass it to the field.
    If you are looking to do it automatically without using the SNRO and without coding it, then the answer is no.
    Hope this helps.
    Regards,
    Srikanth

  • To add fields form ztable to VA01

    Hi All,
          I need to add some fields from ZTABLE to transaction va01 and i want to store
    data entered in that fields.
           So that dat should be saved in ztable or stadard table by doing Append structure  .
           And wt code shall i write for saving that data and where it should be added.
    Thanks in advance.
    Aniket

    HI,
    Hi,
    You can do this by implementing one screen exit and couple of usr-exit. For all of the exits given describing below you will need access key.
    1. Field you want in VA01 line item, add them to table VBAP using append strucutre.
    2. You can not show additional fields to the in VA01 where all the lines are display, instead you add the fields on "Additional data B" tab at line item level. To see the Additional data B screen, you can either double-click any line item and go to the very last tab OR use the menu path "Goto -> Item -> More functions -> Addition data B"
    The screen for "Additional data B" is SAPMV45A 8459. Use transaction SE51 to implement this screen. Add these fields as a dictionary fields ( with reference to VBAP custom fields you have defined ).
    3. To implement PBO logic of this screen, you will have to use include MV45AOZZ. This will require access key.
    4. To implement PBI logic of this screen, you will have to use include MV45AIZZ. This will also require access key.
    Please refer to following link for more information on "User-exit in sales document processing"
    http://help.sap.com/saphelp_46c/helpdata/en/1c/f62c7dd435d1118b3f0060b03ca329/frameset.htm
    Regards
    Sudheer

  • F4 help for month and Year field in ztable please

    I have created a ztable. 
    The first field in my ztable is a primary key field and it holds MM/YYYY(eg.  08/2011).
    How ever my requirement is when ever we want to see the output, uer wants F4 help on that fields and when he selects the range , the ztable should display the values in that range.
    For eg.
    1). if user selects   01/2011  to 08/2011 using F4 Help,
    2). then the ztables should display all the records in that range.
    Thanks in advance for your help.
    Best regards,Sam
    Moderator message : Spec dumping / Outsourcing is not allowed.  Thread locked.
    Edited by: Vinod Kumar on Aug 8, 2011 11:17 AM

    Hi Sam,
    Create an F4 help using this FM
    l_t_date" has month and date
    l_f_programm = sy-repid.
        l_f_dynnr    = sy-dynnr.
        CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
          EXPORTING
            retfield         = 'Date'"Field name of coloum of value tab
            dynpprog         = l_f_programm
            dynpnr           = l_f_dynnr
            dynprofield      = <>"Screen field name'
            value_org        = 'S'
            callback_program = l_f_programm
            callback_form    = ''
          TABLES
            value_tab        = l_t_date"Value table for date and month
    *      FIELD_TAB        = L_T_RETURN
            return_tab       = l_t_return_tab
          EXCEPTIONS
            parameter_error  = 1
            no_values_found  = 2
            OTHERS           = 3.
        READ TABLE l_t_return_tab INDEX 1.
        IF  sy-subrc = 0 .
        <fields> = l_t_return_tab-fieldval.
        ENDIF.
    Regards,
    Amit
    then filter the ztable accordingly

  • Adding a New Field to Ztable...Missing in SM30

    I added a new key field to a Z table. When I do an SM30, or the already created custom transaction to maintain te table the key field is not there.
    I even did an SE14 and did an "adjust" to the Ztable...No luck the key field is not there. However, when I do an SE16 to view the table, I see the added key field, blank of course.
    What step did I miss?
                  Thank-You

    Hi,
    You have to re-generate the Table maintenance..
    Go to SE11..
    Give the table name..Press change..
    In the menu..UTILITIES -> TABLE MAINTENANCE GENERATOR..
    Press change (pencil button)..
    Press expert mode..Press select all..
    Press enter.
    It will re-generate the table maintenance..
    Thanks,
    Naren

  • Auto populate for fields in ZTable

    Hi
    I created a Z Table with 10 Fields,Out of those 2 fields are timestamp and Created by.
    Timestamp and Created by are made Output only fields in Table Maintenance Generator
    SE11> ZTable>Table Maintenance Generator>Environment>Modifications-->Events
    Type -5  concatenate sy-datum sy-uzeit into ZTable-Timestamp.
    With which when user performs a manual posting in the table and save a record in SM30 the Timestamp is populated automatically.
    Similar to these how can i Auto Populate the Created By with the user id (logon id) of the user who made the posting.
    I tried to create a new event of type-5   - System is not allowing me to create a event another event of same time
    How can i enhance the exisisting event so that i can get Auto Populate of Created By
    Thanks in advance

    Hi friend,
    Put your code which populate user name inside form of event 5 (maybe below your existence code).
    regards,

  • Search help for a field in ztable

    Good day everyone!
    I want to create a search help for a field. I have a field 'country' in my Ztable. Now I want to create a search help for that field so that they appear in the SM30 transaction while entering the data into the table. How can I do that?
    thanks.

    First of all if the field is country and you want to display all the countries avaiable in SAP in the search help then yuo dont need to create search help for that. For that field put the data element LAND1. The F4 help will automatically appear in SM30 and when you press F4 all the countries will be displayed in the hit list.
    Now suppose there is a case where you want to display selected values only  and not all the countries in your search help then one way is to create a z-table of countries and put all the countries you want in that table then create z-data element and z-domain for that country field and in domain give the table as a value table.
    Another way is to create a view for T005  and T005T table and give the selection conditions as per your requirement and then create the search help with this view and attache the search help to your country field.

  • Declaring a text field in ztable

    dear all,
    iam trying to declare a text field for inserting comments in a ztable. first iam declaring it in a code and updating it in to a ztable through program. this text field is given in alv as edit mode than tere some text is maintained in output(i.e in editable alv) than user when clicks save than total records r updated to ztable.
    my problem is that this text field is taking only 5 to 6 letters as input.
    With regards,
    Prasadbabu.

    Hi,
    While building  a fieldcatalogue for output table set the parameter  OUTPUTLEN of fielcatalogue equal to the lenghth of the number of characters u want to enter.This will allow u to enter as much characters u want.
    i_fieldcat           TYPE STANDARD TABLE OF lvc_s_fcat,
    wa_fieldcat        LIKE LINE OF i_fieldcat.
    wa_fieldcat-outputlen  =  '20'.
    APPEND wa_fieldcat TO i_fieldcat.
    Hope this Helps!!!!!!!!
    Edited by Tejaswini Khante

  • What should be the data type for a field in ztable?

    i am desing a ztable , wht should be the datatype for a field if i want to enter values like -1.5 and -2.5 , negative values with decimals what should be the data type???

    declare as P type. TYPE P DECIMALS 1
    Type P data allows digits after the decimal point. The number of decimal places is generic, and is determined in the program. The value range of type P data depends on its size and the number of digits after the decimal point. The valid size can be any value from 1 to 16 bytes. Two decimal digits are packed into one byte, while the last byte contains one digit and the sign. Up to 14 digits are allowed after the decimal point. The initial value is zero. When working with type P data, it is a good idea to set the program attribute Fixed point arithmetic.Otherwise, type P numbers are treated as integers.
    You can use type P data for such values as distances, weights, amounts of money, and so on.
    Also check this link.
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb2fd9358411d1829f0000e829fbfe/content.htm
    Regards,
    Maha

  • Hi add fields in ztable user name system time and date urgent

    i have to add three new fields in my z table
    a)user name
    b)system time
    c)date
    suppose if anyone update my ztable then the above three fields should catch the values as which user change the ztable at what time and on which date
    plzzzzzz help
    urgent
    saurabh

    To create the fields use the following field types.
    CPUTD - for Date
    CPUTM - for Time
    USNAM - User name.
    when updating the table pass the system variable.
    sy-datum - for date
    sy-uzeit - for time
    sy-uname - for user name

  • Adding some fields to ztable.

    Hi friends,
       i want to add menge from mseg table and lbkum from mbew table into my ztable which has MANDT TEMPLATE ITEM PHASE
      MATERIAL MFRNR these fields but at the appending it is giving error that  Error in ALTER TABLE generation for table ZPSYS
    can you please tell me how can i rectify this error?
    Regards,
    bikash

    Hi in SE11 ,
    Use menu as below.
    UTILITY----
    >DATABASE OBJECT......>DATBASE UTILITY......>ACITIVATE NAD ADJUST DATABSE.
    then Click on YES
    Press F3 and acivate your table.
    Cheers,
    Pravin

  • How can we hide the key fields of ztables in sm30 display?

    experts.. pls help me....

    Hi,
    Use events in table maintenance generator '05' and write the code.
    Go to se11-table name-utilities-table maintenance generator-extras-events in table maintenance generator . In the source code
    Put form hide.
    <code>.
    endform.
    Or.
    In SE80
    Goto Function Group
    Then click on Screen
    Then click on Element List Tab
    Below u can see list of ur fields strting with ZTT-......
    And against that u can have to uncheck the checkbox in INPUT column ......
    So that the input for the field will be disabled..... when u go in edit mode......
    Regards,
    Jagadish

  • Concatinating of fields in ztable

    Hi experts....
    I have one z table in this  it has 8 fields, when user enters data in the first 7 fields at sm30, than that data will be concatinated with the "/'" mark in 8 th field.. please help me to solve this....

    You may have to do this in a slightly roundabout way.
    Instead of having the user enter into table entry through SM30, you would need to write a program that calls transaction sm30 from inside. Attach a transaction code to your program and ask the user to use this in place of SM30. Once the user is done and presses back, the control is back in your program. Now you can programmatically do the concatenation and inclusion of other characters into the 8th field and do a bdc all transaction SM30 to update with the calculated value.
    I would assume there is some purpose why this is being done. So, as a sweetener your program may trigger the next step after your 8th field update has completed.
    The assumption above is, the table has not many rows [10K or less] you can read all entries of the table to carpet bomb with 8th filed creation for all rows every time. Else it is tricky to figure out which ones changed in the latest update. If you have to do that, look at SCU3 and the SAP standard report program under "Evaluate Logs" button, with your table having "Log Data Changes" checked in table technical settings and your Basis folks permitting table logging.

  • In Ztable creation, How can we display error message for a 'To date' field.

    Hi all,
    I have a requirement like this.
    There r two fields in ztable. From date and To date.
    The field 'To date' in table ZKM007 is taking before date than From date field.
    To date should always be greater than from date i need to throw an  error or don't  allow to enter date  if date is less than From date.
    How can we do this?
    Can any one help on this?
    Rewards to all.
    Thanks & Regards,
    Anu.

    I have written below code at event "Creating a new entry" (05) in table maintainance generator.But it is not working. If we give the to date < From date ,
    it is saving.
    Can any one help on this code? Pls Give me code And which event i have to put this?
    ***INCLUDE LZEXE3F01 .
    FORM AT_entry.
    IF ZEXE3-TODATE LT ZEXE3-FROMDATE.
      MESSAGE I001(0) WITH 'ENTER TO DATE GREATER THAN FROM DATE'.
    ENDIF.
    ENDFORM.
    Rewards to all.
    thanks
    Anu.

  • Validation of a field in select statement

    In selection screen, skunag(vbrk-kunag) and swerks(vbrp-werks) fields are there.these two fileds are obligatory.
    If skunag field values start with 'P'.I have to remove the initial 'P' in that values,because I have to validate that field with ztable-kunag.
    i have written folllowing way.but no result.
    AT SELECTION-SCREEN ON SKUNAG.
    PERFORM check_skunag.
    form check_skunag.
    data: p_kunag(10) type c.
    if not skunag is initial.
        p_kunag = skunag+4(4).
        move p_kunag to skunag.
    endif.
    endform.
    one more thing this skunag filed is also using in another form for database selection.In this form i want to use the above skunag field, after validation....
    form gatherdata.
      SELECT vbeln kunag zuonr vkorg waerk fkart FROM vbrk INTO CORRESPONDING FIELDS OF TABLE itab
            WHERE vbeln IN svbeln
           AND   kunag IN <b>skunag</b>.
    endform.
    how can i write the above scenario...
    thanks in advance,
    fractal

    Looks like skunag is a select-option. In that case, it will be very difficult to validate it because if the user enters a range like P00001 to P99999, how are you going to validate this against the Z table.
    First you will have to restrict the user from using ranges. That you can do by defining your skunag with no-intervals. Then you will be able to validate that easily as user can only enter single values, no ranges.
    You need to have your validation in AT SELECTION-SCREEN ON <b>skunag-low</b>.
    In your FORM check_skunag, you need to change the code as follows
    data: p_kunag(10) type c.
    LOOP AT skunag.
    *-- only if the first character is P
      CHECK skunag-low+0(1) = 'P'.
      p_kunag = skunag-low+1(remove the first P)
    *-- check against the Z table with p_kunag
      SELECT KUNAG FROM ztable WHERE kunag = p_kunag.
      IF sy-subrc <> 0.
    *-- invalid KUNAG
        DELETE skunag.
      ELSE.
    *-- If you want to move the value without P back into
    *   your skunag then do the following
        MOVE p_kunag to skunag-low.
        MODIFY skunag.
      ENDIF.
    ENDLOOP.

Maybe you are looking for

  • Some loops missing when saved as archive

    I added a blue or audio loop to 2 songs in order for the save as archive to be available. It enabled the save as archive button. I saved them as archives but all the loops are not there. 2 other songs are fine. What can I do?

  • Help with Places no longer working in iPhoto 9

    Since an update about a month ago, Places no longer works with iPhoto 9 version 8.1.2 (424). Where GPS data is present, the map tries to open but all I get is a dull green screen where the map should be. My Nikon View software Geotag works with the s

  • Icons in workspace are not displayed

    Hi there, after installation of EPM 11.1.2.1 icons in the workspace are not shown correctly. In the Explorer window the Icons for folders and documents are missing. Any ideas? regards, Bernd

  • Areca Cards

    Hey Harm, In my several months without Internet, I've fallen waaaay behind in my tech reading.  What's your opinion of the I/O controllers on Areca cards?  What to look for, what to avoid, that kind of thing.  (3 drive RAID 3 planned.)

  • Ejb datacontrol, query panel with timestamps / date field errors

    Hi, I made an ejb datacontrol on a session bean in jdev 11g ps1 and used the named criteria of this entity in the data control to create an af querypanel. This works well. first thing I cannot configure a date picker with time on this timestamp field