Help with creating a user function

Hi, I have never created a user function in Oracle and need some help. My function takes in a variable, reads the table looking for a match of the first 2 characters, if not found tries based on the first character. This is what I have so far:
CREATE function Get_Country_Of_Origin
(av_SERIAL_ID varchar2)
RETURN varchar2
IS
var_country varchar2;
BEGIN
--If match on first 2 characters of serial id return that value
SELECT DESCRIPTION INTO var_country
FROM M4LOADER.SUPPLIER_TYPE
WHERE SUPPLIER_TYPE = LEFT(av_SERIAL_ID,2)
--Else If match on first character of serial id return that value
SELECT DESCRIPTION INTO var_country
FROM M4LOADER.SUPPLIER_TYPE
WHERE SUPPLIER_TYPE = LEFT(av_SERIAL_ID,1)
--Else return nothing
return var_country;
END;

<FONT FACE="Arial" size=2 color="2D0000">
CREATE function Get_Country_Of_Origin (av_SERIAL_ID varchar2)
RETURN varchar2
IS
var_country varchar2;
BEGIN
--If match on first 2 characters of serial id return that value
<font color="#ff8040">Are you sure that the following will return only one single value </font><font color="#800000">( if TO MANY ROWS ARE FOUND then ..?)</font>
SELECT DESCRIPTION INTO var_country FROM M4LOADER.SUPPLIER_TYPE WHERE SUPPLIER_TYPE = <font color="#0080c0">substr(av_SERIAL_ID,0,2)</font>
--Else If match on first character of serial id return that value
<font color="#0d1099">IF var_country is null then</font>
SELECT DESCRIPTION INTO var_country FROM M4LOADER.SUPPLIER_TYPE WHERE SUPPLIER_TYPE = <font color="#0080c0">substr(av_SERIAL_ID,0,1)</font>
<font color="#0d1099">End if;</font></font>
return var_country;
END;
-SK
</FONT>

Similar Messages

  • Noob help with creating a new function module

    Hi everyone,
    I'm just learning SAP and trying to integrate a WMS system towards it and I'm losing hair over it hehehe
    The scenario is that I want to extract Purchase Order Rows details and that's not a hard thing to do since there are multiple BAPIs that can be invoked, for example BAPI_PO_GETDETAIL.
    I'm using .NET Connector 3 to talk to SAP.
    The problem however is that I want to see how many articles that have already been delivered into the warehouse using BAPI_GOODSMVT_CREATE. There is no information returned when using BAPI_PO_GETDETAIL that specifies that a Purchase Order Row has a quantity of 30 and that 20 has already been delivered.
    That information can be retrieved by using BAPI_GOODSMVT_GETITEMS.
    The problem with using BAPI_GOODSMVT_GETITEMS is that it returns all of the rows and I am only interrested in retrieveing the rows with quantity for a specific purchase order.
    So i decided to create my own BAPI or Function Module (or whatever it's called) that would take a PO_NUMBER and PO_ITEM and return the quantity of already delivered items. For example if one of the PO Rows (10) has 100 items and there has been 2 partial deliveries of 20 and 30. The function should return the value of 50 because it's the sum of 20 and 30.
    My code looks like this:
    FUNCTION ZBAPI_GOODSMVT_GETITEMS.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(PO_NUMBER) TYPE  BSTNR
    *"     VALUE(PO_ITEM) TYPE  EBELP
    *"  EXPORTING
    *"     REFERENCE(ENTRY_QNT) TYPE  ERFMG
    SELECT SUM( MENGE ) INTO ENTRY_QNT FROM MSEG
      WHERE
      EBELN = PO_NUMBER AND
      EBELP = PO_ITEM.
    ENDFUNCTION.
    The problem is that when i try to Activate it it says:
    REPORT/PROGRAM statement missing, or program type is INCLUDE.          
    What am i missing? Is there an easier way to extract already delivered quantities when extracting PO information?

    A document was produced for Designer 7.1 and the principles still apply.
    http://partners.adobe.com/public/developer/en/pdf/lc_designer_perf_guidelines.pdf
    You can poke around here as well....
    http://help.adobe.com/en_US/livecycle/9.0/designerHelp/index.htm
    Steve

  • Help with creating a shuffleList function...

    I have the following function, which creates and populates a vertical column of draggable clips and populates the dynamic text boxes within the movie clips with data from an xml file, effectively creating an ordered list of movie clips
    The code works fine, but I am having some difficulties with the shuffleList function. What I would like to do is randomly sort the data contained in dragClip1.answerText.text so that the ordered list of movie clips becomes an unordered list.
    Any ideas would be greatly appreciated.
    ~Chipleh
    function createListContent(evt:Number):void{
      var xmlObjectListLength:Number = xml.sim.bodyText.page[evt].para.q.length(); 
      for(var i:Number = 0; i<xmlObjectListLength;i++)
       var listObjectAttributes:XMLList = xml.sim.bodyText.page[evt].para.q;  
       addChild(objectContainer);
       var dragClip1:dragClip = new dragClip();        
       objectContainer.addChild(dragClip1);    
       dragClip1.answerText.text = xml.sim.bodyText.page[evt].para.q[i];    
       dragClip1.x = 0;
       dragClip1.y = (dragClip1.height * i);  
       dragClip1.totalClips = xmlObjectListLength;     
      shuffleList(dragClip1.totalClips);
    function shuffleList(listCount:Number,dragClipListText:Array):void
    //Not really sure where to start with this function or how to go about shuffling the data
    for(var i:Number = 0; i<listCount+1;i++)
       var aTarget:Object = objectContainer.getChildByName("listObject" + i);
       var theTarget:Object = objectContainer.getChildByName("listObject" + i);  
       theTarget.answerText.text = aTarget.answerText.text;

    Hi Ned,
    Thanks for the reply. I have come up with this function, using an array like you suggested, but htere is one problem:
    function shuffleList(listCount:Number,dragClipListText:Array):void
    var tempArr:Array = new Array();
    for(var i:int =0;i<listCount;i++)
      var theTarget:Object = objectContainer.getChildByName("listObject" + i);
      trace("theTarget = "+ theTarget.name);
      tempArr.push(theTarget.answerText.text);
    trace("temp = "+ tempArr);
    var myArray:Array = new Array();
    while (tempArr.length > 0)
      var r:int = Math.floor(Math.random()*tempArr.length);
      myArray.push(tempArr[r]);
      tempArr.splice(r,1);
      var listString:String = myArray.toString();
      trace("listString = "+ listString);
      theTarget.answerText.text = listString;
    trace("myArray =" +myArray)
    I can see my arrays of data being traced out properly, but all the data is populated in the last movie clip, per:
    theTarget.answerText.text = listString;
    So the data in all movie clips remain uneffected aside from the last clip, which is populated with ALL the listString data.
    Hopefully this is clear. If not, let me know and I will try to clarify further.
    ~Chipleh

  • Help with creating a user input BTree for hierarchy structure

    I have been trying to create code that takes a user input string
    ex: a:b,c;b:g,h,j;g:k,m;b:u
    note: (the above string is then stored into a string array such in the format a:bc;b:ghj;g:km;b:u after it is verified that the hierarchy order is correct)
    The string is read in such that the any value before the : is a parent and its childern continue until a ; is found. Anyway verifying the sting I have accomplished and I have been able to input the string into a modified binary tree as long as there are only 2 childern per parent and graphically represents its structure of hierarchy. The problem is that each parent can have more the two childern.
    I have been working with the BTree class and find its output similar to what I am wanting which would represent a hierarchy of objects (files, employees, etc...) anyway I have been stumped as to how to get the above string into a format that can then create the correct BTree output without hard code.
    If any one has any suggestions on how to turn the data, in the string array into a usable format to create the correct BTree output, I would greatly appreciate it.
    In the above example the string array, a:bc;b:ghj;g:km;b:u would have a desired ouput of
    a
    ..b
    ....g
    ......k
    ......m
    ....h
    ....j
    ....u
    ..c
    Thanks
    Shane

    OOPS! I ment to say JTree not BTree

  • I need help with creating some formulas

    I'm not sure if anyone around here can help me, but I'm trying to create a Numbers document and need some help with creating a formula/function.
    I have a column of amounts and I would like to create a formula which deducts a percentage (11.9%) and puts the result in another column.
    If anyone can help me, it would be greatly appreciated.

    Here is an example that shows one way to do this:
    The original data is in column A.  In column B we will store formulas to adjust the amounts:
    1) select the cell where you want to formula (in this case cell B2)
    2) Type the "=" (equal sign):
    3) click cell A2:
    4) now type the rest of the formula which is: "*(100-11.9)/100"  that is asterisk, then open parenthesis, 100 minus eleven point nine close parenthesis forward slash  one hundred
    The Asterisk is the multiply operator  (times) and the forward slash is the division operator (divide)
    now hit return.  select cell B2 and hover the cursor over the bottom edge of the cell:
    drag the little yellow dot down to "fill" the formula down as needed.

  • Problem with creating new user in portal = portlet is not visible

    Hi,
    I've got a problem with creating new users in portal. In the Administer tab of the builder is the user portlet not visible.
    How can I make this portlet visible?
    Please Help
    thank you...
    Gilbert

    Hi..my problem slightly similar.
    I created one new user, and didn't select anything from "Public Groups Assignment" and "Privilege Assignment" for him.
    I expect the user will be a public user.
    But, when he try to logged in the portal,
    He cannot see all the PORTLETS related to database values..
    All he can see just LINKS -that all in my portal right now beside the report from database that the user cannot see :)
    So, what did i do wrong?
    Plz Advise, and thanks.

  • Help with creating a Quiz

    Hey i need help with creating a quiz with scoring and all.
    I need a helping hand so if you can get me started that
    would help a lot.
    Use the Question class to define a Quiz class. A
    quiz can be composed of up to 25 questions. Define the add method
    of the Quiz class to add a question to a quiz. Define the giveQuiz
    method of the Quiz class to present each question in turn to the user,
    accept an answer for each one, and keep track of the results. Define
    a class called QuizTime with a main method that populates a quiz,
    presents it, and prints the final results.
    // Question.java Author: Lewis/Loftus/Cocking
    // Represents a question (and its answer).
    public class Question implements Complexity
    private String question, answer;
    private int complexityLevel;
    // Sets up the question with a default complexity.
    public Question (String query, String result)
    question = query;
    answer = result;
    complexityLevel = 1;
    // Sets the complexity level for this question.
    public void setComplexity (int level)
    complexityLevel = level;
    // Returns the complexity level for this question.
    public int getComplexity()
    return complexityLevel;
    // Returns the question.
    public String getQuestion()
    return question;
    // Returns the answer to this question.
    public String getAnswer()
    return answer;
    // Returns true if the candidate answer matches the answer.
    public boolean answerCorrect (String candidateAnswer)
    return answer.equals(candidateAnswer);
    // Returns this question (and its answer) as a string.
    public String toString()
    return question + "\n" + answer;
    }

    Do you know why this lazy f&#97;rt-&#97;ss is back? Because when he posted his homework last week, some sorry-assed idiot went and did it for him.
    http://forum.java.sun.com/thread.jspa?threadID=5244564&messageID=10008358#10008358
    He didn't even thank the poster.
    It's the same problem over and over again. You feed the bears and it only teaches them to come back for handouts.
    My polite suggestion to the original poster: please do your own f&#117;cking homework.

  • I need help with Creating Key Pairs

    Hello,
    I need help with Creating Key Pairs, I generate key pais with aba provider, but the keys generated are not base 64.
    the class is :
    import java.io.*;
    import java.math.BigInteger;
    import java.security.*;
    import java.security.spec.*;
    import java.security.interfaces.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import au.net.aba.crypto.provider.ABAProvider;
    class CreateKeyPairs {
    private static KeyPair keyPair;
    private static KeyPairGenerator pairGenerator;
    private static PrivateKey privateKey;
    private static PublicKey publicKey;
    public static void main(String[] args) throws Exception {
    if (args.length != 2) {
    System.out.println("Usage: java CreateKeyParis public_key_file_name privete_key_file_name");
    return;
    createKeys();
    saveKey(args[0],publicKey);
    saveKey(args[1],privateKey);
    private static void createKeys() throws Exception {
    Security.addProvider(new ABAProvider());
    pairGenerator = KeyPairGenerator.getInstance("RSA","ABA");
    pairGenerator.initialize(1024, new SecureRandom());
    keyPair = pairGenerator.generateKeyPair();
    privateKey = keyPair.getPrivate();
    publicKey = keyPair.getPublic();
    private synchronized static void saveKey(String filename,PrivateKey key) throws Exception {
    ObjectOutputStream out= new ObjectOutputStream(new FileOutputStream(filename));
    out.writeObject(key);
    out.close();
    private synchronized static void saveKey(String filename,PublicKey key) throws Exception {
    ObjectOutputStream out= new ObjectOutputStream( new FileOutputStream(filename));
    out.writeObject(key);
    out.close();
    the public key is:
    �� sr com.sun.rsajca.JSA_RSAPublicKeyrC��� xr com.sun.rsajca.JS_PublicKey~5< ~��% L thePublicKeyt Lcom/sun/rsasign/p;xpsr com.sun.rsasign.anm����9�[ [ at [B[ bq ~ xr com.sun.rsasign.p��(!g�� L at Ljava/lang/String;[ bt [Ljava/lang/String;xr com.sun.rsasign.c�"dyU�|  xpt Javaur [Ljava.lang.String;��V��{G  xp   q ~ ur [B���T�  xp   ��ccR}o���[!#I����lo������
    ����^"`8�|���Z>������&
    d ����"B��
    ^5���a����jw9�����D���D�)�*3/h��7�|��I�d�$�4f�8_�|���yuq ~
    How i can generated the key pairs in base 64 or binary????
    Thanxs for help me
    Luis Navarro Nu�ez
    Santiago.
    Chile.
    South America.

    I don't use ABA but BouncyCastle
    this could help you :
    try
    java.security.Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    java.security.KeyPairGenerator kg = java.security.KeyPairGenerator.getInstance("RSA","BC");
    java.security.KeyPair kp = kg.generateKeyPair();
    java.security.Key pub = kp.getPublic();
    java.security.Key pri = kp.getPrivate();
    System.out.println("pub: " + pub);
    System.out.println("pri: " + pri);
    byte[] pub_e = pub.getEncoded();
    byte[] pri_e = pri.getEncoded();
    java.io.PrintWriter o;
    java.io.DataInputStream i;
    java.io.File f;
    o = new java.io.PrintWriter(new java.io.FileOutputStream("d:/pub64"));
    o.println(new sun.misc.BASE64Encoder().encode(pub_e));
    o.close();
    o = new java.io.PrintWriter(new java.io.FileOutputStream("d:/pri64"));
    o.println(new sun.misc.BASE64Encoder().encode(pri_e));
    o.close();
    java.io.BufferedReader br = new java.io.BufferedReader(new java.io.FileReader("d:/pub64"));
    StringBuffer keyBase64 = new StringBuffer();
    String line = br.readLine ();
    while(line != null)
    keyBase64.append (line);
    line = br.readLine ();
    byte [] pubBytes = new sun.misc.BASE64Decoder().decodeBuffer(keyBase64.toString ());
    br = new java.io.BufferedReader(new java.io.FileReader("d:/pri64"));
    keyBase64 = new StringBuffer();
    line = br.readLine ();
    while(line != null)
    keyBase64.append (line);
    line = br.readLine ();
    byte [] priBytes = new sun.misc.BASE64Decoder().decodeBuffer(keyBase64.toString ());
    java.security.KeyFactory kf = java.security.KeyFactory.getInstance("RSA","BC");
    java.security.Key pubKey = kf.generatePublic(new java.security.spec.X509EncodedKeySpec(pubBytes));
    System.out.println("pub: " + pubKey);
    java.security.Key priKey = kf.generatePrivate(new java.security.spec.PKCS8EncodedKeySpec(priBytes));
    System.out.println("pri: " + priKey);
    catch(Exception e)
    e.printStackTrace ();
    }

  • Help with creating a form, I want to add a check box to enable me to unlock certain fields and deselect the block again

    Help with creating a form, I want to add a check box to enable me to unlock certain fields and deselect the block again

    Look to the right under "More Like This". Your issue has been discussed many many times. The error you are seeing is because you do not have enough free "contiguous" space on your hard drive. Read the other threads that address this issue to find how to solve the issue.
    Or, put "The disk cannot be partitioned because some files cannot be moved" into the search box at the upper right of this page.

  • Need help with creating a brush

    Hi guys,
    I wanted to ask for help with creating a brush (even a link to a tutorial will be goon enough ).
    I got this sample:
    I've created a brush from it, and i'm trying to get this kind of result:
    but it's only duplicates it and gives me this result:
    Can someone help me please understand what i need to define in order to make the brush behave like a continues brush instead of duplicate it?
    Thank you very much
    shlomit

    what you need to do is make a brush that looks like the tip of a brush. photoshop has several already but you can make your own that will be better.
    get a paintbrush and paint a spot kind of like what you did but dont paint a stroke. make it look kindof grungy. then make your brush from that, making sure to desaturate it and everything.
    EDIT:
    oh, and if you bring the fill down to like 10-20% your stroke will look better

  • I need help with creating PDF with Preview...

    Hello
    I need help with creating PDF documetns with Preview. Just a few days ago, I was able to create PDF files composed of scanned images (notes) and everything worked perfectly fine. However, today I was having trouble with it. I scanned my notebook and saved 8 images/pages in jpeg format. I did the usual routine with Preview (select all files>print>PDF>save as PDF>then save). Well this worked a few days ago, but when I tried it today, I was able to save it, but the after opening the PDF file that I have saved, only the first page was there. The other pages weren't included. I really don't see anything wrong with what I'm doing. I really need help. Any help would be greatly appreciated.

    I can't find it.  I went into advanced and then document processing but no batch sequence is there and everything is grayed out.
    EDIT: I realized that you cant do batch sequences in standard.  Any other ideas?

  • In need of immediate help with FCP new user taking over colleagues position

    Good Morning. I am in urgent need of some help with a specific final cut pro question. My coworker and I have been working on a video project for our employer, a university. He ran the editor (FCP) and I ran the logistics of setting things up, keeping the contacts and scheduling, etc.
    He has left until late August and there are two major typos in his work which is posted to the web at the moment. I need to correct these typos and have less than a faint idea of how to do it.
    First of all, what is the file's last three letters? (.doc, .mov, etc...)
    Second, can I edit this as easily as I think I can? Just click in the text file along the bottom timeline and edit that way?
    How do I export the movie as an mp4 file after i have edited it.
    Anything else that would be deemed helpful is always appreciated!
    I really appreciate the help. I was never trained on this program because I never needed to be. Unfortunately, as it turns out, I did.
    Thanks for the help!

    You need to locate the Project file. Which will be somewhere in your colleague's User space.
    In the Finder, press command and F to activate the Find function.
    Make sure the following parameters are set:
    Search *This Mac* and Contents
    Kind is Documents
    Type the project name.
    The icon looks like this:
    Double click it to launch Final Cut Pro with the project.
    To locate the text overlay, click on the Timeline to make it active. Use the down arrow on your keyboard to jump from one cut to the next. The text overlay will look similar to this:
    Double click on the Text clip. This will place it in the Viewer (the left "monitor").
    Click the "Controls" tab above the Viewer and make your changes. Press Return.
    Clicking anywhere in the Timeline once more will update it.
    Make sure that no clips are selected and the Timeline is the active window.
    Go to the menu bar: File > Export > Using QuickTime Conversion.
    In the window that opens, make sure that Format is set to QuickTime Movie.
    Click the Options button. Look at the top of the next window.
    Does it say Compression Setting: H264? If it does, great.
    If not, click the settings button and choose H264 from the *Compression Type* button.
    At bottom left, drag the Quality slider to Best. Click OK.
    This brings you back to the previous window.
    Click on Size if you need to change something -there are a number of presets, but you can choose a custom size if you wish. Click OK.
    That window is dismissed and returns you to the Save dialog.
    Type a name and choose a destination for your file.
    Message was edited by: Nick Holmes

  • Help with creating a list

    I query id values from one of my table.
    I need to come up with a list that looks like:
    id='123' OR id='234' OR id='002' OR id='345' OR id='435'
    I came up with 123,234,002,345,435 and '123' , '234' , '002' , '435' and also '123' OR '234' OR '002' OR '435'
    but very frustrated with putting id= on each list element to come up with id='123' OR id='234' OR id='002' OR id='345' OR id='435'
    Can anyone think of a technique to create such a list dynamically from a query result?
    Thanks!

    You could create a user defined function that converts a comma delimited list of values into one formatted with id's and OR's.
    Here is a quick sample which has NOT been tested.
    <cffunction name="customFormatOrList" returntype="string" output="no" hint="Converts comma delimited list to OR query string">
        <cfargument name="inputList" type="string" required="yes" hint="Comma delimited list" />
        <cfset var local=StructNew() />
        <cfset local.resultString="" />
        <cfloop list="#arguments.inputList#" index="local.idx">
            <!--- add 'OR' if this is not the first item --->
            <cfif Len(local.resultString) gt 0>
                <cfset local.resultString="#local.resultString# OR " />
            </cfif>
            <cfset local.resultString="#local.resultString#id='#local.idx#'" />
        </cfloop>
        <cfreturn local.resultString />
    </cffunction>

  • Help Pls: Create New User Form and display custom attributes +++

    Hi All,
    I am trying to create a user screen where a user would see all the organizations he is responsible for and clicking on the organization he would see the certain attribute of all the users that belong to the organization. (Kind of report)
    Account attribute need to be defined with 2 custom attributes:
    1. Organizations Responsible for
    2. Belongs to which organization.
    3. Status
    The first 2 attributes are used to define the organization heirarchy (we can't use the org heirarchy as is in IDM).
    I am just starting on the Sun IDM (very new to the product). Could you please let me know how this could be done? Which form I need to modify and any other changes I need to make.
    Thanks a lot and have a pleasant day,
    Ritesh
    PS: I know this is a long question but i really don't know how to better explain the problem.

    A workaround is to write a PL/SQL procedure to render the custom item (pass in each attribute as a paramter and then use htp.p to print it whatever format you want). You can then disable the default display of attributes (i.e. edit the style so none of the attributes are rendered).
    Hope that helps,
    Mark

  • Help with creating Box2D bodies dynamically, according to shape.

    Hello everyone,
    I am having some issues on how to dynamically create Box2D bodies dynamically, according to the shape.
    So far this is how I've layed out my project in attempt to do this...
    Main class:
    package
    //imports
              public class Architecture extends Sprite
                        public var world:b2World;
                        public var stepTimer:Timer;
                        public var mToPx:Number = 20;
                        public var pxToM:Number = 1 / mToPx;
                        protected var shapeObjectDirector:ShapeObjectDirector = new ShapeObjectDirector();
                        public function Architecture()
      //gravity
                                  var gravity:b2Vec2 = new b2Vec2(0, 10);
                                  world = new b2World(gravity, true);
      //debug draw
                                  var debugDraw:b2DebugDraw = new b2DebugDraw();
                                  var debugSprite:Sprite = new Sprite();
                                  addChild(debugSprite);
                                  debugDraw.SetSprite(debugSprite);
                                  debugDraw.SetDrawScale(mToPx);
                                  debugDraw.SetFlags(b2DebugDraw.e_shapeBit);
                                  debugDraw.SetAlpha(0.5);
                                  world.SetDebugDraw(debugDraw);
      //declarations
                                  var wheelBuilder:WheelBuilder = new WheelBuilder(world, pxToM);
                                  createShape(wheelBuilder, 0, 0, 0, 0);
      //timer
                                  stepTimer = new Timer(0.025 * 1000);
                                  stepTimer.addEventListener(TimerEvent.TIMER, onTick);
                                  stepTimer.start();
                        private function createShape(shapeObjectBuilder:ShapeObjectBuilder, pxStartX:Number, pxStartY:Number, mVelocityX:Number, mVelocityY:Number):void
                                  shapeObjectDirector.setShapeObjectBuilder(shapeObjectBuilder);
                                  var body:b2Body = shapeObjectDirector.createShapeObject(pxStartX * pxToM, pxStartY * pxToM, mVelocityX, mVelocityY);
                                  var sprite:B2Sprite = body.GetUserData() as B2Sprite;
                                  sprite.x = pxStartX;
                                  sprite.y = pxStartY;
                                  this.addChild(sprite);
                        public function onTick(event:TimerEvent):void
                                  world.Step(0.025, 10, 10);
                                  world.DrawDebugData();
    ShapeObjectBuilder class:
    package
    //imports
              public class ShapeObjectBuilder
                        public var body:b2Body;
                        protected var circle:b2CircleShape;
                        protected var polygon:b2PolygonShape;
                        protected var world:b2World, pxToM:Number;
                        protected var fixtureDef:b2FixtureDef;
                        protected var bodyDef:b2BodyDef;
                        protected var fixture:b2Fixture;
                        protected var startingVelocity:b2Vec2;
                        protected var sprite:B2Sprite;
                        protected var restitution:Number, friction:Number, density:Number;
                        protected var mStartX:Number, mStartY:Number;
                        protected var mVelocityX:Number, mVelocityY:Number;
                        protected var Image:Class;
                        public function ShapeObjectBuilder(world:b2World, pxToM:Number)
                                  this.world = world;
                                  this.pxToM = pxToM;
                        public function createCircleShape():void
                                  circle = new b2CircleShape();
                                  createFixtureDef(circle);
                        public function createPolygonShape():void
                                  polygon = new b2PolygonShape();
                                  createFixtureDef(polygon);
                        public function createFixtureDef(shape:b2Shape):void
                                  fixtureDef = new b2FixtureDef();
                                  fixtureDef.shape = shape;
                                  fixtureDef.restitution = restitution;
                                  fixtureDef.friction = friction;
                                  fixtureDef.density = density;
                        public function createBodyDef(mStartX:Number, mStartY:Number):void
                                  bodyDef = new b2BodyDef();
                                  bodyDef.type = b2Body.b2_dynamicBody;
                                  bodyDef.position.Set(mStartX, mStartY);
                        public function createBody():void
                                  body = world.CreateBody(bodyDef);
                        public function createFixture():void
                                  fixture = body.CreateFixture(fixtureDef);
                        public function setStartingVelocity(mVelocityX:Number, mVelocityY:Number):void
                                  startingVelocity = new b2Vec2(mVelocityX, mVelocityY);
                                  body.SetLinearVelocity(startingVelocity);
                        public function setImage():void
                                  sprite = new B2Sprite();
                                  var bitmap:Bitmap = new Image();
                                  sprite.addChild(bitmap);
                                  bitmap.x -= bitmap.width / 2;
                                  bitmap.y -= bitmap.height / 2;
                        public function linkImageAndBody():void
                                  body.SetUserData(sprite);
                                  sprite.body = body;
    ShapeObjectDirector class:
    package builders
    //imports
              public class ShapeObjectDirector
                        protected var shapeObjectBuilder:ShapeObjectBuilder;
                        public function ShapeObjectDirector()
      //constructor code
                        public function setShapeObjectBuilder(builder:ShapeObjectBuilder):void
                                  this.shapeObjectBuilder = builder;
                        public function createCircleObject():void
                                  shapeObjectBuilder.createCircleShape();
                        public function createPolygonObject():void
                                  shapeObjectBuilder.createPolygonShape();
                        public function createShapeObject(mStartX:Number, mStartY:Number, mVelocityX:Number, mVelocityY:Number):b2Body
                                  shapeObjectBuilder.createBodyDef(mStartX, mStartY);
                                  shapeObjectBuilder.createBody();
                                  shapeObjectBuilder.createFixture();
                                  shapeObjectBuilder.setStartingVelocity(mVelocityX, mVelocityY);
                                  shapeObjectBuilder.setImage();
                                  shapeObjectBuilder.linkImageAndBody();
                                  return shapeObjectBuilder.body;
    WheelBuilder class:
    package builders
      //imports
              public class WheelBuilder extends ShapeObjectBuilder
                        [Embed(source='../../lib/Basketball.png')]
                        public var Basketball:Class;
                        public function WheelBuilder(world:b2World, pxToM:Number)
                                  super(world, pxToM);
                                  restitution = 1.0;
                                  friction = 0.0;
                                  density = 5.0;
                                  Image = Basketball;
                                  circle.SetRadius(15 * 0.5 * pxToM);
    The above code did have some errors, but even if it worked I wouldn't have been happy. It was just my attempt at what I'm trying to achieve.
    What I want to is be able to call a function in my "Main" class to create a shape (Circle body or Polygon body), like so... createShape(wheelBuilder, 0, 0, 0, 0);
    I would like to make the class ShapeObjectDirector and ShapeObjectBuilder to be able to handle b2CircleShape() and b2PolygonShape(), but my problem is creating constants to handle both datatypes all in the one class.
    Basically, I need help with building a class to create shapes on the fly, with minimal code in the Main class. What do you guys suggest? I would be grateful for one of you's who have enough experience with this kind of thing to write me a post on how I can tackle this problem, all responses appreciated.
    Thankyou,
    Brendon.

    UIImageView initWithImage takes a UIImage* as a parameter, not NSString*. So load your image into a UIImage first
    UIImage *ballImage = [UIImage imageNamed:@"Ball.png"];
    UIImageView *tempStart = [[UIImageView alloc] initWithImage:ballImage];

Maybe you are looking for