How to use the rpad, lpad or substr function in the out put files in oracle plsql?

Hi all

Declare
   v_account varchar2(30) := '01-000-000-0000-000-0000 ';
   v_WIP varchar2(30) := '123435';
   v_code varchar2(30) := 'PURCHASE_PRICE_VARIANCE';
   v_dr number:=248.8;
   v_cr number:=248.8;
Begin
 dbms_output.put_line('        Account Segments          '||'   '||' WIP Entity Name      '||'   '||'       Accounting class code          '||'  '||' Accounted DR '||'  '||' Accounted CR ');
 dbms_output.put_line('----------------------------------'||'   '||'----------------------'||'   '||'--------------------------------------'||'  '||'-------------------'||'  '||'------------------- ');
 dbms_output.put_line(rpad(v_account,30)||rpad(v_WIP,25)||rpad( v_code,34)||' '||rpad(v_dr,20)||rpad(v_cr,20));
End;

Out to

       Account Segments                  WIP Entity Name             Accounting class code               Accounted DR          Accounted CR 
----------------------------------   ----------------------   --------------------------------------  -------------------  ------------------- 
01-000-000-0000-000-0000                  123435                   PURCHASE_PRICE_VARIANCE               248.8                    248.8               

But if I v_code value is "ABCDGE" then

        Account Segments                  WIP Entity Name             Accounting class code                 Accounted DR      Accounted CR 
----------------------------------   ----------------------   --------------------------------------  -------------------  ------------------- 
01-000-000-0000-000-0000                     123435            ABCDGE                             248.8               248.8               

can you please help me how to solve this type of questions?

Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production

Thank you

Rajesh123,


If you do not have it still works, you can use the code below.

This is based on the details below, you have given

Account Segments--> left-aligned--> to 26 characters

Entity name WIP--> Center--> 18 characters length

Accounting--> left-aligned class--> character length 28 code

NTS DR--> Center--> 15 character length

NTS-> Center CR--> 15 character length

I used the function line given by Karthick_Arp.

Add the function below to your package:

function align(p_str in varchar2, p_justify varchar2, p_size integer)
  return varchar2
  is
    l_str    varchar2(4000);
    l_temp   number;
    l_temp_1 number;
    l_left   number;
    l_right  number;
  begin
    case p_justify
      when 'RIGHT' then
        l_str := lpad(p_str, p_size);
      when 'LEFT' then
        l_str := rpad(p_str, p_size);
      when 'CENTER' then
        l_temp   := p_size - length(p_str);
        l_temp_1 := l_temp/2;
        l_left   := floor(l_temp_1);
        l_right  := ceil (l_temp_1);  

        l_str := lpad(' ', l_left) || p_str || rpad(' ', l_right);
      else
        raise_application_error(-20001, 'Invalid parameter for p_justify specified -- ' || p_justify);
    end case;  

    return l_str;
end;

Then copy the Sub lines to your code.

 fnd_file.put_line(fnd_file.output,align('Account Segments','CENTER',26)||'   '||align('WIP Entity Name','CENTER',18)||'   '||align('Accounting class code','CENTER',28)||'   '||align('Accounted DR','CENTER',15)||'   '||align('Accounted CR','CENTER',15));
 fnd_file.put_line(fnd_file.output,'--------------------------'||'   '||'------------------'||'   '||'----------------------------'||'   '||'---------------'||'   '||'---------------');
 fnd_file.put_line(fnd_file.output,align(nvl(v_account,' '),'LEFT',26)||'   '||align(v_WIP,'CENTER',18)||'   '||align(v_code,'LEFT',28)||'   '||align(v_dr,'CENTER',15)||'   '||align(v_cr,'CENTER',15));

Once the above code 2 is added to your code, please compile the package and run the concurrent program. Check your output.

See you soon

AJ

Tags: Database

Similar Questions

  • I can't find a newer version of adobe flash player for ubuntu 14.04, I tried to use the apt version but it wouldn't work and I don't know how to use the tar.gz files and install, I think the current version to .deb

    I can't find a newer version of adobe flash player for ubuntu 14.04, I tried to use the apt version but it wouldn't work and I don't know how to use the tar.gz files and install, I think the current version to .deb

    Hi LF12,.

    The latest version of Flash Player for Linux is 11.2.202.400.  The current versions of Flash Player are displayed here http://www.adobe.com/software/flash/about/. The versions on the page are updated with each new version.

    --

    Maria

  • How to use the programe of java in oracle

    Hello Expert,

    My Config is: -.

    Forms [32 bit] Version 11.1.1.3.0 (Production)

    JDeveloper - 10.1.3

    I want to use the java programe in the form builder. I create a java class in Jdeveloper.

    package demo;

    import java.net.InetAddress;

    import java.net.NetworkInterface;

    java.net.SocketException import;

    java.net.UnknownHostException import;

    public class get_info {}

    Public Shared Sub main (String [] args) {}

    ch_add();

    }

    public static ch_add() Sub

    {

    InetAddress ip;

    try {}

    IP = InetAddress.getLocalHost ();

    /*System.out.println ("current IP address:" + ip.getHostAddress ());  */

    NetworkInterface network = NetworkInterface.getByInetAddress (ip);

    Mac Byte [] = network.getHardwareAddress ();

    /*System.out.print ("MAC address current :");   */

    StringBuilder sb = new StringBuilder();

    for (int i = 0; i < mac.length; i ++)

    {

    SB. Append (String.format ("% 02 X %s", mac [i], (I < mac.length - 1)?)) "-" : ""));

    }

    System.out.println (SB. ToString());

    } catch (UnknownHostException e) {}

    e.printStackTrace ();

    } catch (SocketException e) {}

    e.printStackTrace ();

    }

    }

    }

    and Formweb.cfg and default.env and also add in Form_class_path. After that, I import this java in forms.

    Code genertated-

    PACKAGE get_info BODY IS

    --

    -DO NOT EDIT THIS FILE - it is machine generated!

    --

    args NYI. ARGLIST;

    Constructor for signature (V)

    New FUNCTION RETURN ORA_JAVA. JOBJECT IS

    BEGIN

    args: = NULL;

    RETURN (JNI. NEW_OBJECT ("demo/get_info", "(V)", args));

    END;

    -Method: main ([Ljava/lang/String ;) V

    Main PROCEEDINGS)

    A0 ORA_JAVA. JACOB) IS

    BEGIN

    args: = NYI. CREATE_ARG_LIST (1);

    NYI. ADD_OBJECT_ARG (args, a0, ' [Ljava/lang/String ;');)

    NYI. CALL_VOID_METHOD (TRUE, NULL, "demo/get_info', 'hand', ' ([Ljava/lang/String ;)) V ", args);

    END;

    -Method: ch_add (V)

    PROCEDURE ch_add IS

    BEGIN

    args: = NULL;

    NYI. CALL_VOID_METHOD (TRUE, NULL, "demo/get_info", "ch_add", "(V)", args);

    END;

    -Method: wait (J) V

    PROCEDURE to wait)

    obj ORA_JAVA. JOBJECT,

    NUMBER of a0) IS

    BEGIN

    args: = NYI. CREATE_ARG_LIST (1);

    NYI. ADD_LONG_ARG (args, a0);

    NYI. CALL_VOID_METHOD (FALSE, obj, "demo/get_info", "expect", "(J) V", args);

    END;

    -Method: wait (V)

    PROCEDURE to wait)

    obj ORA_JAVA. JOBJECT) IS

    BEGIN

    args: = NULL;

    NYI. CALL_VOID_METHOD (FALSE, obj, "demo/get_info", "expect", "(V)", args);

    END;

    -Method: wait (JI) V

    PROCEDURE to wait)

    obj ORA_JAVA. JOBJECT,

    NUMBER of a0,

    The a1 NUMBER) IS

    BEGIN

    args: = NYI. CREATE_ARG_LIST (2);

    NYI. ADD_LONG_ARG (args, a0);

    NYI. ADD_INT_ARG (args, a1);

    NYI. CALL_VOID_METHOD (FALSE, obj, "demo/get_info", "expect", "V (JI)", args);

    END;

    -Method: equals (Ljava/lang/object ;) Z

    FUNCTION is equal to)

    obj ORA_JAVA. JOBJECT,

    A0 ORA_JAVA. JOBJECT) RETURN BOOLEAN IS

    BEGIN

    args: = NYI. CREATE_ARG_LIST (1);

    NYI. ADD_OBJECT_ARG (args, a0, ' object java/lang / "");

    BACK TO JNI. CALL_BOOLEAN_METHOD (FALSE, obj, "demo/get_info", "equal to", "(Ljava/lang/object ;)) Z', args);

    END;

    -Method: toString () Ljava/lang/String;

    FUNCTION toString)

    obj ORA_JAVA. JOBJECT) RETURN VARCHAR2 IS

    BEGIN

    args: = NULL;

    BACK TO JNI. CALL_STRING_METHOD (obj, "demo/get_info", "toString", "() Ljava/lang/String"; FALSE, args);

    END;

    -Method: hashCode () I have

    FUNCTION (hashCode

    obj ORA_JAVA. JOBJECT RETURN NUMBER) IS

    BEGIN

    args: = NULL;

    BACK TO JNI. CALL_INT_METHOD (FALSE, obj, "demo/get_info", "hashCode", ' () I ", args");

    END;

    -Method: getClass () Ljava/lang/class;

    FUNCTION getClass)

    obj ORA_JAVA. ORA_JAVA RETURN JOBJECT). JOBJECT IS

    BEGIN

    args: = NULL;

    BACK TO JNI. CALL_OBJECT_METHOD (obj, "demo/get_info", "getClass", "() Ljava/lang/class"; FALSE, args);

    END;

    -Method: notify (V)

    Notification PROCEDURE)

    obj ORA_JAVA. JOBJECT) IS

    BEGIN

    args: = NULL;

    NYI. CALL_VOID_METHOD (FALSE, obj, "demo/get_info', 'prevent',"(V)", args);

    END;

    -Method: notifyAll () V

    PROCEDURE notifyAll)

    obj ORA_JAVA. JOBJECT) IS

    BEGIN

    args: = NULL;

    NYI. CALL_VOID_METHOD (FALSE, obj, "demo/get_info", "notifyAll", "(V)", args);

    END;

    BEGIN

    NULL;

    END;

    Now, I want to call the o/p of the Java programe in the oracle text element. Please help me. It is very urgent. I'm not good in Java.

    It is all explained in http://fdtool.free.fr/forms-pjc-bean/first-bean/first_bean.pdf

    In essence, you need:

    -a Java class that extends from oracle.forms.ui.VBean where you must implement getProperty, as stated in article method

    -a unique property of your choice name

    -forms of type point area of bean that should be visible and on a canvas

    -you could then call your method using get_custom_property (, 1, )

    Just adapt the example comes from the tutorial above. You can of course also use the FBean package so you will not need to extend kifani but simply to any class that extends from container. As a first step, maybe you must redo the complete tutorial to get a handle on the how and the why.

    see you soon

  • How to use the JKS-based Keystore in Oracle 11g SOA

    I'm doing FTPS on remote server of third party (with UNIX operating system) using SOA 11 g adapter FTP. I installed and configured vsftpd and generated vsftpd.pem file on the remote server certificate.
    Follow the steps mentioned in http://download.oracle.com/docs/cd/E17904_01/integration.1111/e10231/adptr_file.htm#CIABDGCF

    In one step "Adjusting upward the FTP Oracle adapter" walletLocation is necessary, then I went through the steps mentioned in http://download.oracle.com/docs/cd/E17904_01/core.1111/e10105/wallets.htm#CHDGIJDC

    (Tried using both 1) JKS Keystore Management 2) portfolio management

    Impossible to find two of them in the Oracle 11g SOA em but the steps do not match.

    Can someone tell me how to use JKS Keystore or portfolio management?

    Thank you very much!!

    Concerning
    Yogesh

    Hi yogesh,

    I think that the portfolio can be created from the FMW console only if the HTTP server is installed and available. If there is no Oracle HTTP server, configure a specified in the.

    [http://download.oracle.com/docs/cd/E12839_01/doc.1111/e14260/toc.htm |] Oracle HTTP Server installation]

    Agress,
    Neeraj Sehgal

  • How to use the Precendence_rules.csv file to define the rules of priority in integration ATG-short

    Hello

    I'm integrating ATG 10.1.2 Catalogue of products with short. I am successfully able to publish data from ATG to store short CASE file and run the update of the base.

    I used the model of integration of catalog:

    http://docs.Oracle.com/CD/E35827_01/ToolsAndFrameworks.310/PDF/ProductCatalogDTGuide.PDF

    The problem I am facing is, I have a dimension created from the structure of the ATG catalogue. I also have dimensions that I created in developer studio.

    I want to apply priority rules on the dimension, which I created in dev studio. using the Sun. by coming to the dimval CASE record store. Because I'm not able to view the dimensions to the CASE record store I can't define the rules of priority in dev studio.

    Page no. 12 of the guide above, they suggested that I use this precedence_rules.csv file in < app >/config/api - entry directory. I tried all the possible permutations and combinations to add priority rules by using this file, but they still do not work (I checked in JSP REF). All other prules I created in the studio of dev (between dims created in dev.studio) are being created.

    Another doubt, I must settle prules on a Sun. Val a dimension named product.category (coming from the record store Sun). Is this format I used below correct (I used the Windows format of folklore as suggested in the guide)?

    Precedence.source_dimension_name, Precedence.source_dimval_spec, Precedence.target_dimension_name, Precedence.type

    response of Product.Category/Accessories, 102016, Accessories 1, sheet

    Ideas/pointers would be greatly appreciated.

    I have no way of knowing that my FCM/ConfigurationGeneratorForge is actuall read this file because it didn't we no log being generated.

    Thank you

    Arjun

    I think I understood the problem I had. FCM correctly reads the precedence_rules.csv file, but it supports the priority rules for the dimensions of the root level. I could create a prule for "product.category" (it is NOT a dimension of autogen) which is a dimension created by the components of indexing of the ATG.

    It supports mapping prules for dims created in dev.studio and those created from on the side of the ATG and vice versa.

    When I tried to add the "product.category/accessories" as the size of the CBC in the priority rule, it does not work. "Accessories" are a dimval under "product.category" and it doesn't have an entry in the record of the CASE of the application schema store. I guess that's the problem that prevents me to add prules to the dimval.

    If someone managed to create the rule of priority for a dimval, let me know.

    Any help would be greatly appreciated.

    Kind regards

    Arjun

  • How to use the search otherwise condition as

    Oracle 9i

    Hi all

    I work in the management of control here, we have a table named as OE_ORDER_LINES_ALL and the name of the column called UPI, and its length is 16 tank.

    Now the customer has the UPI with 13 tank and now, I need to check if all the IPUS are in the table.
    I have almost 600 of the UPI and I can't able to use as an operator. Y at - it one option other than as an operator.

    For example

    Resemble UPI this 050 009714373007G, but the customer gave this G 009714373007.

    Is there a UPI then I would use like this

    "Select upi in oe_order_lines_all where the upi as ' 009714373007 G %.

    If there is more than 2 UPIs how to use the search condition

    Any help is highly appricatable

    Thanks and greetings
    Srikkanth.M

    If you know that you will benefit from a number of values of UPI 13 characters and you should look for if there are rows in the table that match the 13 first characters

    select upi
      from oe_order_lines_all
     where substr(upi,1,13) IN( '009714373007G', <> )
    

    Justin

  • With no headphone jack, how to use the iPhone in my car 7

    Okay, so here's the challenge.  I have a power source and a headphone and not Bluetooth.  It works perfectly with iPhones before 7.  But with 7, it isn't possible to use the same configuration I had for years.  I own my car, and I have no interest in buying a new car just to support a new phone.  And since this will be a problem for the years to come if I stay with Apple, I would like to know what are the solutions are available.

    So, how to use the new iPhone 7 while remaining responsible and using my car speakers?  Dongles Bluetooth that I need to reload, it's probably not.

    Thus, looking for ideas that might have people.  I can't be the only one with this concern.

    It's almost a certainty that a third party adapter will appear quickly. The new Macbook has a single port usb - c and people asked the same question, 'how to load and use USB at the same time." There are today dozens of solutions for the Macbook, and then it will be with the iPhone 7. An adapter with a 3.5 mm jack and a port of loading Lightening would be my guess. Kickstarter entrepreneurs are probably already working on it.

  • How to use the capture and the print button

    I tried to figure out how to use the capture and the "print" button, or add or what you call. I press it and the whole page of a different color changes, so I try to cut the section I want but I don't know how to send it to the printer. Can someone help me with this. I'm not at savvy with tech stuff, but when I find a recipe or something and it doesn't have an option to print a certain area, I can't understand how to use it?

    Thank you

    Andi Starbuck

    That happens to me is, I click and drag to make a rectangle of yellow selection, and as soon as I raise my finger on the mouse button, the part I've selected is captured as an image, a new tab opens and preview before printing, the image display. I can use the installation of the Page or simply print. But if I close the preview, this temporary image vanishes and I'm back on the page where I started. You see something different?

  • How to use the activity monitor to remove MegaBAckup on my mAc Book PRO?

    How to use the activity monitor to remove MegaBAckup on my mAc Book PRO?

    Download and run MalwareBytes. Malwarebytes was developed by one of our colleagues here to ASC. He received rave reviews and is on the more proven anti-malware for Mac software.

  • How to use the utility disk first aid for hard drive internal el captian

    How to use the utility disk first aid for hard drive internal el captian

    Select the drive and click first aid.

    If something is not repairable because this is the system drive, then you need to start using the recovery partition and run disk utility it.

  • How to use the Print Screen function?

    I've seen various descriptions of how to use the print screen function.

    It would be nice to actually tell one that works.  None have worked for me.

    [Fn] and Prt SCr does not work.

    CTRL and Prt SCr does not work.

    CTRL, Alt, and Prt SCr does not work.

    [Fn], Ctrl and Prt SCr does not work.

    If anyone knows the correct method to activate the screen capture function which would be a good thing.

    From the looks of things, HP has a big problem with this function.

    Here's a microsoft articleon the use of the screenshot function.

    This should answer your questions.

    Thanks for taking a peek.

  • How to use the acronym

    How to use the acronym instead of this?

    Please explain

  • How to use the adapter from the wall with my Mac Pro laptop?

    How to use the adapter from the wall with my Mac Pro laptop?

    The AC wall connector is not compatible with the outlet on the MBP?  As the MBP charger will work from 100v to 240v, a transformer is necessary.  You need a converter that connects to the power outlet home and is compatible with your MBP.  You can buy the Apple travel kit:

    http://www.Apple.com/shop/product/MD837AM/A/Apple-world-travel-adapter-Kit

    Or you can use a single specific converter for the geographical area:

    http://www.Amazon.com/orei-grounded-universal-adapter-Singapore/DP/B004SCSV2U/re f = sr_1_4? ie = UTF8 & qid = 1460735377 & sr = 8-4 & keywords = us + in + uk + power + adapter

    (it is a UK USA example)

    Or you can get the converter that adapts the charger directly:

    http://www.Amazon.com/HIOTECH%C2%AE-extension-charger-connecting-specification/d p/B00MA48JZW/ref = sr_1_3? ie = UTF8 & qid = 1460735486 & sr = 8-3 & keywords = us + in + uk + power + ad aptor + apple + charger + cord

    (again, this is for a UK plug.)

    Ciao.

  • SOLUTION - How to use the remote on the Satellite X 200 with Win7 64 bit

    Here is the description how to use the remote control on the Satellite X 200-2 b with Windows 7 64 bit.

    Thanks for the link.

    It will be fine if some owner of Satellite X 200 can confirm.

  • How to use the software keyboard Toshiba 50L9450VE TV?

    I just bought a LED TV model 50L9450VE. When installing, I need to enter the password for the wifi network. The remote doesn't have a keyboard of the letter, and the TV shows a soft keyboard to enter the password. How to use the software keyboard? I can't figure out how to get the cursor in it; the manual does not say, and I can't find the information online. Thank you.

    Hershel

    Suppose you are from Israel? Although this model is not made for the EU market, but probably for the Asian market, it looks like the European L93 series.
    You will find how to operate the software keyboard (page 52): http://www.toshiba-om.net/pdf/manual...h-Specific.pdf

Maybe you are looking for