Auto Generated No with Date and year

I m using this method to create a auto generated no.
in pre-insert trigger
declare
          v_l varchar2(10);
     begin
          select max(doc_no) into v_l from Table ;
          if v_l is not null or v_l<>0 then
               :table.doc_no:= v_l+1;
          else
               :table.doc_no:=1;     
          end if;
     exception
          when no_data_found then
          :table.doc_no:=1;
     end;I want to generate auto generate no|| month||year
please guide me

Kame wrote:
I want to generate auto generate no|| month||year
please guide meYou can get an auto-generated number using SEQUENCE in Oracle.
Do you have a specific date column in your table from which you need to get the MONTH and YEAR Data?
To get MONTH, you can use something like:
TO_CHAR(your_date_column, 'MONTH')To get YEAR, you can use
TO_CHAR(your_date_column, 'YYYY')your_date_column should contain data of date datatype.
Examples:
SQL> CREATE SEQUENCE SEQ
  2     MINVALUE 1
  3     MAXVALUE 999999999
  4     START WITH 1
  5     INCREMENT BY 1
  6  /
Sequence created.
SQL> SELECT SYSDATE FROM Dual
  2  /
SYSDATE
10-JUN-09
SQL> SELECT TO_CHAR(sysdate, 'MONTH') FROM Dual
  2  /
TO_CHAR(SYSDATE,'MONTH')
JUNE
SQL> SELECT TO_CHAR(sysdate, 'YYYY') FROM Dual
  2  /
TO_C
2009
SQL> SELECT      TO_CHAR (SEQ.NEXTVAL)
  2           || TO_CHAR (SYSDATE, 'fmMONTH')
  3           || TO_CHAR (SYSDATE, 'YYYY')
  4              auto_gen
  5    FROM   DUAL
  6  /
AUTO_GEN
1JUNE2009
SQL> /
AUTO_GEN
2JUNE2009
SQL> /
AUTO_GEN
3JUNE2009
SQL> /
AUTO_GEN
4JUNE2009
SQL>Hope this helps.
Regards,
Jo
Edit: Corrected Query

Similar Messages

  • HR -- adding year with date and month

    Hi all,
    Can any one let me know what is the logic for adding Year with date and month in HR.
    ex: 01.10.2008   from this date it should be 2 years.
    thnks
    joshi.

    Hi
    u can add days to the date directly ....
    if u have the date V_DATE of type sy-datum u can add directly number of days to get disired date ..
    v_date1 =  v_date + 365 .
    hope it helps ..........

  • Help on export sybase iq tables with data and import in another database ?

    Help on export Sybase iq 16 tables with data and import into another database ?

    Hi Nilesh,
    If you have table/index create commands (DDLs), you can create them in Developper and import data using one of methods below
    Extract/ Load table
    Insert location method : require IQ servers to be entered in interfaces file
    Backup/Restore : copy entire database content
    If you have not the DDLs, you can generate them using IQ cockpit or SCC.
    http://infocenter.sybase.com/help/topic/com.sybase.infocenter.dc01773.1604/doc/html/san1288042631955.html
    http://infocenter.sybase.com/help/topic/com.sybase.infocenter.dc01840.1604/doc/html/san1281564927196.html
    Regards,
    Tayeb.

  • EBS-R12 Generate XML (with data) from Embedded Data Definition

    Hi
    I'm new to running XMLP/BIP in EBS.
    I have found the extensive set of data definitions and templates in EBS and they work great out of the box.
    I, however, need to make template modifications.
    To this end, a correctly structured XML data template - containing all the data fields - is needed for loading into the template-builder in Word.
    If for example I take the embedded R12 data definition - XLAJELINESRPT.xml - for Posted Payable Invoices, and load it into the template builder, it provides the structure of the data template and not the structure of the output XML data.
    I have tried several ways to run the Data definition through XMLP using the concurrent manager attempting to intercept the generated XML (with data) but it either completes the process and uses the linked output template - producing the PDF - or other output - or if I remove the (output template altogether) it fails with an error.
    Maybe I'm missing an obvious step, but there has to be a way of taking the very comprehensive Data Definitions embedded in R12 EBS and using them in custom report templates.
    If I've totally missed the point, please give me the steps to follow.
    Many thaks in anticipation.
    Mike MacMurray

    HI Mike,
    You cannot load your Data Template into the MS Word Template Builder plugin, as it cannot be run to generate XML this way.
    You have two options to get the data from an XML Publisher Report run as a concurrent program in EBS.
    1) Using the XML Publisher Administrator responsibility, set an end date for both the Data Defintion and Template Definitions associated with the XLAJELINESRPT report.
    2) Leave the concurrent program, Data Defintions and Template Definitions exactly as they are and run the report. Once the report has completed, select the Concurrent Request, click "Diagnostics" then click "View XML". This will open the XML in a new browser window. You can then right click, View Source and then save this document locally.
    You can then load this XML into the MS Word Template Builder and start building your template.
    I hope this helps.
    Regards,
    Cj

  • Pivot with Month and Year

    Hi all Thanks in Advance
    I need help in Pivoting Data
    SELECT ID,MONTH,COUNT FROM TABLE_PIVOT ORDER BY ID,MONTH
    ID     MONTH          COUNT
    10     10/01/2009     60
    10     11/01/2009     80
    10     12/01/2009     78
    10     01/01/2010     81
    10     02/01/2010     73
    10     03/01/2010     84
    10     04/01/2010     100
    10     05/01/2010     107
    10     06/01/2010     90
    10     07/01/2010     0
    10     08/01/2010     0
    10     09/01/2010     73
    20     10/01/2010     71
    20     11/01/2010     76
    20     12/01/2010     79
    20     01/01/2011     79
    20     02/01/2011     81
    20     03/01/2011     88
    20     04/01/2011     97
    20     05/01/2011     87
    20     06/01/2011     97I tried to pivot with below query
    SELECT ID,
    SUM(DECODE(to_char(month,'MM'),'01',count,0)) " Jan",
    SUM(DECODE(to_char(month,'MMYY'),'02',count,0)) Feb,
    SUM(DECODE(to_char(month,'MM'),'03',count,0)) Mar,
    SUM(DECODE(to_char(month,'MM'),'04',count,0)) Apr,
    SUM(DECODE(to_char(month,'MM'),'05',count,0)) May,
    SUM(DECODE(to_char(month,'MM'),'06',count,0)) June,
    SUM(DECODE(to_char(month,'MM'),'07',count,0)) July,
    SUM(DECODE(to_char(month,'MM'),'08',count,0)) August,
    SUM(DECODE(to_char(month,'MM'),'09',count,0)) September,
    SUM(DECODE(to_char(month,'MM'),'10',count,0)) October,
    SUM(DECODE(to_char(month,'MM'),'11',count,0)) November,
    SUM(DECODE(to_char(MONTH,'MM'),'12',count,0)) December
    FROM Table_PIVOT
    GROUP BY ID
    ORDER BY ID
    ID      Jan     FEB     MAR     APR     MAY     JUNE     JULY     AUGUST     SEPTEMBER     OCTOBER     NOVEMBER     DECEMBER
    10      81     0     84     100     107     90     0     0          73          60          80          78
    20      79     0     88     97     87     97     0     0          0          71          76          79I want output to display the column names with Month and Year like below
    ID     Oct-2009     Nov-2009     Dec-2009   Jan-2010  Feb-2010 ................... OCT-2010  NOV-2010 DEC-2010 JAN-2011 FEB-2011 ......
    10     60          80          78          81          73     ...................
    20                                                                    71           76          79     79          81
    CREATE TABLE "TABLE_PIVOT"
       (     "ID" NUMBER,
         "MONTH" DATE,
         "COUNT" NUMBER
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('10/01/2009','MM/DD/YYYY'),60);
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('11/01/2009','MM/DD/YYYY'),80);
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('12/01/2009','MM/DD/YYYY'),78);
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('01/01/2010','MM/DD/YYYY'),81);
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('02/01/2010','MM/DD/YYYY'),73);
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('03/01/2010','MM/DD/YYYY'),84);
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('04/01/2010','MM/DD/YYYY'),100);
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('05/01/2010','MM/DD/YYYY'),107);
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('06/01/2010','MM/DD/YYYY'),90);
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('07/01/2010','MM/DD/YYYY'),0);
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('08/01/2010','MM/DD/YYYY'),0);
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('09/01/2010','MM/DD/YYYY'),73);
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('10/01/2010','MM/DD/YYYY'),71);
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('11/01/2010','MM/DD/YYYY'),76);
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('12/01/2010','MM/DD/YYYY'),79);
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('01/01/2011','MM/DD/YYYY'),79);
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('02/01/2011','MM/DD/YYYY'),81);
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('03/01/2011','MM/DD/YYYY'),88);
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('04/01/2011','MM/DD/YYYY'),97);
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('05/01/2011','MM/DD/YYYY'),87);
    Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('06/01/2011','MM/DD/YYYY'),97);
    COMMIT;

    Hi,
    user1849 wrote:
    Any Sample code is appreciated
    I didn't see any solution for following one in your linklI think Centinul was specifically referring to:
    Help for a query to add columns
    but other links from
    SQL and PL/SQL FAQ
    may help you more.
    >
    Re: How to pipeline a function with a dynamic number of columns?
    Posted: May 9, 2006 2:58 PM in response to: Billy Verreynne Reply
    Interesting stuff! It's going to take me awhile to digest it.
    For what it's worth, I was trying to build a pivoting function that would take a MYTABLE table like this:
    YEAR CITY X Y
    2000 BAL 95 96
    2000 BOS 101 101
    2001 BAL 92 94
    2001 BOS 101 101
    2002 BAL 98 98
    2002 BOS 98 99
    2003 BAL 95 96
    2003 BOS 105 104
    and allow me to do something like:
    CREATE VIEW MYPIVOT
    AS
    SELECT *
    FROM TABLE (PIVOT(MYTABLE, [with other params]))
    and get the following view MYPIVOT on the table:
    YEAR BOS_X BOS_Y BAL_X BAL_Y
    2000 101 101 95 96
    2001 101 101 92 94
    2002 98 99 98 98
    2003 105 104 95 96
    Where the number of distinct CITY values will vary over time. I am able to build the query I need dynamically, but since the CITY data values in the original table change, the columns are not necessarily static from invocation to invocation. Therefore I didn't want to just create a view using the dynamic SQL once, because it may need to be created next time I need to access the view. I wanted to be able to access the pivoted data on demand.A pipelined function is your best bet for that.
    I couldn't do was be able to execute the query and treat it as a pipelined function, hence my original question.Sorry, I don't understand.
    I'll dig into the code above to see if it does what I wanted, but if someone has a better suggestion on how to approach this, I'd be interested in hearing it.A completely different approach is String Aggregation , where you would get output like this:
    YEAR  TXT
            BOS_X    BOS_Y    BAL_X    BAL_Y
    2000      101      101       95       96
    2001      101      101       92       94
    2002       98       99       98       98
    2003      105      104       95       96Note that this output contains 6 rows and 2 columns. On the first row, year is NULL and txt='  BOS_X    BOS_Y    BAL_X    BAL_Y'. You can do this is pure, static SQL, without knowing the number of cities in advance.

  • Auto Populating List with Dates

    I'd like to create a SharePoint list wherein each row/item has a Start Date and End Date along with some other fields.  Each item will correspond with a week and I'd like to pre-populate the list with a good number of "weeks".
    Not too hard (if tedious) to do manually, but is there a clever way to get this done without doing some scripting?

    Hi,
    According to your post, my understanding is that you want to auto populate list with Dates.
    I recommend that you can use caculated column.
    You can use the formual as: =Created+7. Then return date type as Date and Time.
    More information:
    Date and time formulas
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Month to Date and Year to Date Scenarios

    <b>Dear SAP BI Gurus,
    Can anyone please give me guidance how to create a Month to Date and Year To Date Scenarios (Variables perhaps?) for 0SRR_CF_C1?  The date is in decimal and not DATE format…  I’m assuming the reason for this is to get the Time variance….  Nonetheless, I’d like to create a MTD and YTD scenario for reporting.
    Much Thanks
    Philips Manalaysay</b>

    Hi,
    You should take a look at the blog and doc below.
    /people/vikash.agrawal/blog/2006/10/17/enable-trend-reporting-150-by-manipulating-variable-value
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/25d98cf6-0d01-0010-0e9b-edcd4597335a
    Regards,

  • Tolerance Limits with Date and quantity

    Hi Experts,
    We would like to set the GR Tolerance Limits with Date and qty.
    how to set the Tolerance Limits for Date and quantity..??
    if we created PO 100qty and date 01-05-009.
    if we receive the goods on 20-04-2009 and 50qty...
    For GR .. Migo should be give error message..
    where can i set this Tolerance Limit Configuration.... can u please explin me..
    Thanks in Advance,
    Anthyodaya .

    Go to SPRO - Material Managemetn - LIV - Invoice Block - Set Tolerence limit.
    USe company code and maintain a value for ST
    ST: Date variance (value x days)
    The system calculates for each item the product of amount * (scheduled delivery date - date invoice entered) and compares this product with the absolute upper limit defined. This allows relatively high schedule variances for invoice items for small amounts, but only small schedule variances for invoice items for large amounts.

  • Tp ended with error code 0247 - addtobuffer has problems with data- and/or

    Hello Experts,
    If you give some idea, it will be greatly appreciated.
    This transported issue started coming after power outage, sap system went hard shutdown.
    Then we brought up the system. Before that , we do not have this transport issue.
    our TMS landscape is
    DEV QA-PRD
    SED-SEQSEP
    DEV is having the TMS domain controller.
    FYI:
    *At OS level, when we do scp command using root user, it is fine for any TR.
    In STMS, while adding TR in SEQ(QA system), we  are getting error like this.
    Error:
    Transport control program tp ended with error code 0247
         Message no. XT200
    Diagnosis
         An error occurred when executing a tp command.
           Command:        ADDTOBUFFER SEDK906339 SEQ client010 pf=/us
           Return code:    0247
           Error text:     addtobuffer has problems with data- and/or
           Request:        SEDK906339
    System Response
         The function terminates.
    Procedure
         Correct the error and execute the command again if necessary.
    This is tp version 372.04.71 (release 700, unicode enabled)
    Addtobuffer failed for SEDK906339.
      Neither datafile nor cofile exist (cofile may also be corrupted).
    standard output from tp and from tools called by tp:
    tp returncode summary:
    TOOLS: Highest return code of single steps was: 0
    ERRORS: Highest tp internal error was: 0247

    when we do scp using sm69,
    SEDADM@DEVSYS:/usr/sap/trans/cofiles/K906339.SED SEQADM@QASYS:/usr/sap/trans/cofiles/.
    it throws the error like below,
    Host key verification failed.
                                                                                    External program terminated with exit code 1
    Thanks
    Praba

  • How to forward sms messages via email with date and contact received info

    Does anyone know how to forward sms messages via email with date and contact received info.
    Currently when I forward only the body copy of the sms message is sent in the email.

    This is not currently possible. Sorry.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Using expdp to export a mix of tables with data and tables without data

    Hi,
    I would like to create a .dmp file using expdp, exporting a set of tables with data and another set without data. Is there a way to do this in a single .dmp file? For example, I want all the tables in a schema with data, but for the fact tables in that schema, I only want the fact table objects, not the data. I thought it might be easier to create two separate .dmp files, one for each scenario, but would be nice to have one .dmp file that satisfies my requirement. Any help is appreciated.
    Thanks,
    -Rodolfo
    Edited by: user6902559 on May 11, 2010 12:05 PM

    You could do this with where clauses. Let's say you have 10 tables to export, 5 with data and 5 without data. I would do it like this
    tab1_w_data
    tab2_w_data
    tab3_w_data
    tab4_w_data
    tab5_w_data
    tab1_wo_data
    tab2_wo_data
    tab3_wo_data
    tab4_wo_data
    tab5_wo_data
    I would make one generic query
    query="where rownum = 0"
    and I would make 5 specific queries
    query=tab1_w_data:"where rownum > 0"
    query=tab2_w_data:"where rownum > 0"
    query=tab3_w_data:"where rownum > 0"
    query=tab4_w_data:"where rownum > 0"
    query=tab5_w_data:"where rownum > 0"
    The first query will be applied to all tables that don't have their own specific query and it will export no rows, the next 5 will apply to each of the corresponding table.
    Dean

  • Set up Tolerance Limits with Date and quantity for GR

    Hi Experts,
    We would like to set the GR Tolerance Limits with Date and qty.
    how to set the Tolerance Limits for Date and quantity..??
    if we created PO 100qty and date 01-05-009.
    if we receive the goods on 20-04-2009 and 50qty...
    For GR .. Migo should be give error message..
    where can i set this Tolerance Limit Configuration.... can u please explin me..
    Thanks in Advance,
    Anthyodaya .

    hi,
    You can do one thing...
    Activate the SLED check...
    BY this when the date goes earlier or late from the expected date, then system show you the messages like:
    1. Earliest delivery date is DD.MM.YY..
    2. Expected delivery date was DD.MM.YY...
    In std sap system, the second message is already error message...so when get late delivery then it'll not be possible to maintain the GR...
    For the qty varinace, activate the quantity variance either via over/under delievery tolerances..or
    Via SPRO settings...
    SPRO >> MM >> LIV >> Invoice block >> check for qty tolerances and make the settings as per your requirement...
    Regards
    Priyanka.P

  • Arbitrary change of date and year on photos taken in folder structure

    I run Adobe Photoshop Elements 8.0 in a Microsoft Office 2007 environment originally on a Dell laptop. Before installing Adobe I had a library in My Pictures that I have maintained and uses this structure (folders by year and events). I have moved everything to a stationary computer. Now dates has been changed on the pictures pictures from 2001 has been changed to 2010 also in properties). When adding new folders (by year and months) for transfere of pictures from my camera pictures alrready in the files starts populate the folder just established.
    On the old Dell laptop the correct dates and year are still maintained (used as a second back-up).
    What happens?

    Finally got the date fixed, it was simple once I got palm support. I did a hard reset, then set the date but DID NOT click on TODAY at the bottom of the screen, the secret is to tap on the actual DAY on the calendar, NOT TODAY (after you set the year)
    Post relates to: Tungsten E2

  • Split month, date and year

    How to split month,date and year from date field ? is there any standard function module.

    You can do this.
    data: year(4) type c,
          month(2) type c,
          day(2) type c.
    year = sy-datum(4).
    month = sy-datum+4(2).
    day = sy-datum+6(2).
    write:/ year.
    write:/ month.
    write:/ day.
    Regards,
    Rich Heilman

  • Error? on Example 16-7 XMLFOREST: Generating Elements with Attribute and Ch

    Error in example on page http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14259/xdb13gen.htm#i1028612
    Example 16-7 XMLFOREST: Generating Elements with Attribute and Child Elements
    Example appears as
    SELECT XMLElement("Emp",
                      XMLAttributes(e.first_name ||' '|| e.last_name AS "name"),
                      XMLForest(e.hire_date, e.department AS "department"))
    AS "RESULT"
    FROM employees e WHERE e.department_id = 20;
    1. employees table not qualified as hr.employees
    2. e.department as "department" should be e.department_id as "department"
    corrected would be
    SELECT XMLElement("Emp",
                      XMLAttributes(e.first_name ||' '|| e.last_name AS "name"),
                      XMLForest(e.hire_date, e.department_id AS "department"))
    AS "RESULT"
    FROM hr.employees e WHERE e.department_id = 20;albert

    It was subreport-related, though I still do not know the exact root cause.
    I was having trouble with both the built-in export as well as a custom process.
    Removing the subreports as suggested, I isolated the failure to one of the three subs and rebuilt this subreport from scratch (it was only three fields) and now the report has no trouble with the pdf export. I am not sure if it had a resolvable technical issue or if it was just corrupted, as it is now working, I am not going to expend much energy on finding out.
    Thanks for the suggestion.

Maybe you are looking for

  • TypeError:undefined is not an object message when opening a new window in Bridge

    Every time I open a new window in Adobe Bridge CS6, I get a long error message that says "TypeError: undefined is not an object: onResize()buildUIStack(true,"Cabinet")buildUIStack([TabbedPalette:[objectTabbedPalette]], true,"Cabinet")switchTo([Tabbed

  • Indecipherable core dump on Solaris x86_64

    On a 64-bit Solaris x86 machine (SunOS tempest-solaris 5.10 Generic_141445-09 i86pc i386 i86pc Solaris), I have been running gcc 4.3.4 (configured for i686-pc-solaris2.10) without a hitch. Both dbx 7.8 and gdb 7.1 are able to read core dumps created

  • Some of the application components are missing from the Application directory,

    I need help! Cannot run photostop because it says the above.  Can't uninstall it either or download again.  Using a MAC.  Any ideas how to do this?

  • Sequence conversion

    Hello: I am trying to convert a LabWindows/CVI sequence file to TestStand but I get warnings/errors when opening or running the sequence in TestStand. After converting the file I do a File->Open in the TestStand Sequence Editor and I get a "Open Sequ

  • Approval of Working Time & Multi Level CATS approval

    Hi experts, We have implemented CATS multi level approval as below. 1. In the CATS user exit we call a Workflow which is a multi level workflow. 2. We are using the standard Webdynpro for CATS entry and approval. Problem: Once the first level manager