• Peoplesoft store files/Upload files to database

    Posted on May 31, 2012 by in Other Programming, People Soft

    In this article, we will see step by step procedure to attach a file and store it in the database. The article also shows how to view and delete the uploaded file.

    Assume that you have item table (PS_QNN_ITEM) with ITEM_ID as a key and basic item information such as Item Name, Description etc . Now, you want store an image for each item you can follow the steps below

    Step 1 : Insert FILE_ATTACH_SBR subrecord in to PS_QNN_ITEM, or create new table with FILE_ATTACH_SBR in it. If you create new table, you should preferable have the key(s) of primary table in this table.

    STEP 2 : Place YOURRECORD.ATTACHSYSFILENAME on your Page and place 3 buttons on the page beside the textbox, give the record name as FILE_ATTACH_WRK and field names as ATTACHADD,ATTACHVIEW,ATTACHDELETE for the buttons.

    Step 3 : Open Component –> Click on structure tab –> Browse to the FILE_ATTCH_WRK record.
    a ) Write the below code on FieldChange of ATTACHADD

    Declare Function add_attachment PeopleCode FILE_ATTACH_WRK.ATTACHADD FieldChange;
    Declare Function display_attachment_buttons PeopleCode FILE_ATTACH_WRK.ATTACHADD RowInit;
    
    /*Create unique file name*/
    
    &uniquefilename = %OperatorId | "_" | String(Month(%Date)) | "_" | String(Day(%Date)) | "_" | String(Year(%Date)) | "_" | String(Hour(%Time)) | "_" | String(Minute(%Time)) | "_" | String(Second(%Time));
    
    REM &ATTACHSYSFILENAME = Left(&uniquefilename, 64);
    &ATTACHSYSFILENAME = &uniquefilename;
    &RECNAME = "Record." | Record.YOURRECORD;
    
    add_attachment(URL.GL_FILE_IMPORT, "", "", 0, False, &RECNAME, &ATTACHSYSFILENAME, &ATTACHUSERFILE, 2, &Return_Code);
    
    
    NK_BURG_RNEWDOC.ATTACHSYSFILENAME = &ATTACHSYSFILENAME;
    NK_BURG_RNEWDOC.ATTACHUSERFILE = &ATTACHUSERFILE;
    If (&Return_Code = %Attachment_Success) Then
       display_attachment_buttons(&ATTACHUSERFILE);
       DoSave();
    End-If;
    
    

    b) Write the below code on FieldChange of ATTACHDELETE

    Declare Function delete_attachment PeopleCode FILE_ATTACH_WRK.ATTACHDELETE FieldChange;
    Declare Function display_attachment_buttons PeopleCode FILE_ATTACH_WRK.ATTACHADD RowInit;
    
    delete_attachment(URL.GL_FILE_IMPORT, YOURRECORD.ATTACHSYSFILENAME, YOURRECORD.ATTACHUSERFILE, 2, &Return_Code);
    If (&Return_Code = %Attachment_Success) Then
       display_attachment_buttons(YOURRECORD.ATTACHUSERFILE);
       DoSave();
    End-If;
    
    

    c) Write the below code on FieldChange of ATTACHVIEW

    Declare Function view_attachment PeopleCode FILE_ATTACH_WRK.ATTACHVIEW FieldChange;
    
    view_attachment(URL.GL_FILE_IMPORT, YOURRECORD.ATTACHSYSFILENAME, YOURRECORD.ATTACHUSERFILE, 2, &Return_Code);
    
    

    That’s it you should be able to upload/view delete file following the steps above

    Be Sociable, Share!

    Written by

    Vanamali Juvvadi is a Web enthusiast and loves all things design and technology. Founded qnownow with a group of friends to share anything/everything they know/find on the internet.

    View all articles by

    Email : [email protected]

    One Responseso far.

    1. Zitz says:

      Thank u Sir

    Leave a Reply