How can I convert this UDF to be Dynamic?

Hi there I have this UDF that calls a RFC, currently you can specify which table you want to read from and some input parameters. Could someone help me modify this so that I can specify which RFC to call? It only has to have 1 input parameter so not to worry about that. I am trying to change it to another RFC but it does not work. Heres the original UDF calling a static RFC with any table:
// declare parameters
String returnValue = "";
String rfcXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <ns0:RFC_READ_TABLE xmlns:ns0=\"urn:sap-com:document:sap:rfcfunctions\"><QUERY_TABLE>ZMAPPING_TABLE</QUERY_TABLE><DATA></DATA><FIELDS></FIELDS><OPTIONS><item><TEXT>EAN_UPC =  '"EAN_UPC"'</TEXT></item></OPTIONS></ns0:RFC_READ_TABLE>";
AbstractTrace trace = container.getTrace();
RfcAccessor accessor = null;
ByteArrayOutputStream out = null;
try
// 1. Determine a communication channel (Business system + Communication channel)
Channel channel = LookupService.getChannel(businessSystem,communicationChannel);
// 2. Get a RFC accessor for the channel.
accessor = LookupService.getRfcAccessor(channel);
// 3. Create an XML input stream that represents the RFC request message.
InputStream inputStream = new ByteArrayInputStream(rfcXML.getBytes());
// 4. Create the XML Payload
XmlPayload payload = LookupService.getXmlPayload(inputStream);
// 5. Execute the lookup.
Payload result = null;
result = accessor.call(payload);
InputStream in = result.getContent();
// 6. Create a DOM structure from the input XML
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(in);
NodeList list = document.getElementsByTagName("WA"); // The lookupValue is available as WA tag in the response
Node node = list.item(0);
if (node != null) {
node = node.getFirstChild();
if (node != null) {
returnValue = node.getNodeValue();
// 7. To free resources, close the accessor..
if (accessor!=null) {
try {
accessor.close();
} catch (LookupException e) {
trace.addWarning("Error while closing accessor " + e.getMessage() );
} catch (Exception e) {
trace.addWarning("Error" + e);
// 8. return a single id value to the message mapping
return returnValue;
And here is the one I have dynamically calling a RFC:
// declare parameters
String returnValue = "";
String rfcXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <ns0:" + RFC_NAME + " xmlns:ns0=\"urn:sap-com:document:sap:rfcfunctions\"><INPUT_PAR>Input_Value</INPUT_PAR></ns0:" + RFC_NAME + ">";
AbstractTrace trace = container.getTrace();
RfcAccessor accessor = null;
ByteArrayOutputStream out = null;
try
// 1. Determine a communication channel (Business system + Communication channel)
Channel channel = LookupService.getChannel(businessSystem,communicationChannel);
// 2. Get a RFC accessor for the channel.
accessor = LookupService.getRfcAccessor(channel);
// 3. Create an XML input stream that represents the RFC request message.
InputStream inputStream = new ByteArrayInputStream(rfcXML.getBytes());
// 4. Create the XML Payload
XmlPayload payload = LookupService.getXmlPayload(inputStream);
// 5. Execute the lookup.
Payload result = null;
result = accessor.call(payload);
InputStream in = result.getContent();
// 6. Create a DOM structure from the input XML
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(in);
NodeList list = document.getElementsByTagName("WA"); // The lookupValue is available as WA tag in the response
Node node = list.item(0);
if (node != null) {
node = node.getFirstChild();
if (node != null) {
returnValue = node.getNodeValue();
// 7. To free resources, close the accessor..
if (accessor!=null) {
try {
accessor.close();
} catch (LookupException e) {
trace.addWarning("Error while closing accessor " + e.getMessage() );
} catch (Exception e) {
trace.addWarning("Error" + e);
// 8. return a single id value to the message mapping
return returnValue;
Thanks,
Jan

1)You can check the Second RFC Response Structure using SE37.
Check export structure using Display code.
2)Second way.......
Change the code here
if (node != null) {
returnValue = node.getNodeValue();
if (node != null) {
returnValue = node.getNodeValue();
}else
returnValue = "No WA tag in response";
Now execute the mapping using Test Tab. Now you should see "No WA tag in response" in the target structure for the mapped field.
Edited by: Praveen Gujjeti on Mar 16, 2009 5:26 PM

Similar Messages

  • I have 13 dollars left on an apple store gift card, how can I convert this into money for my iTunes account?

    I have 13 dollars left on an apple store gift card, how can I convert this into money for my iTunes account?

    You can't.

  • How can i convert this data(00000000) into date format(yyyy-MM-dd)

    Hi,
    i am using this method to convert date format from string.
    public static string FormatDate(string inputDate, string inputFormat)
                System.DateTime date = DateTime.ParseExact(inputDate, inputFormat, null);
                string datepresent = DateTime.Now.Date.ToString("yyyy-MM-dd");
                return datepresent;
    its working properly,
    but when input data is like 00000000 i am getting error this is not valid.
    how can i convert this into date format any help..!

    Have you tried the above code:
    I can see it is working with both Date and DateTime destination nodes.
    Map:
    Functoid Parameters:
    Functoid Script:
    public static string FormatDate(string inputDate, string inputFormat)
    string datepresent;
    if (inputDate == "00000000")
    datepresent = "0000-00-00";
    else
    System.DateTime date = DateTime.ParseExact(inputDate, inputFormat, null);
    datepresent = date.ToString("yyyy-MM-dd");
    return datepresent;
    Input:
    <ns0:InputDateString xmlns:ns0="http://DateFormat.SourceSchema">
    <DateString>00000000</DateString>
    </ns0:InputDateString>
    Output:
    <ns0:OutputDate xmlns:ns0="http://DateFormat.DestinationSchema">
    <Date>0000-00-00</Date>
    </ns0:OutputDate>
    If this answers your question please mark as answer. If this post is helpful, please vote as helpful.

  • How can I convert this small pl/sql block in a single query?

    Hello,
    I need to have a single SQL query which gives the same output as the following piece of code, which uses a cursor to iterate on the rows in order to get the informations I need:
    declare
    cursor c(p varchar2) is
    select context_id, id, parent_id
    from CONTEXT_CONTEXT
    start with parent_id is null
    and context_id = p
    connect by prior id = parent_id
    and context_id = p;
    begin
    for r in (select context_id from ALL_CONTEXTS where context_type in ('MYTYPE'))
    loop
    for j in c(r.context_id)
    loop
    -- I want to obtain the values of the following colums from a query:
    dbms_output.put_line(j.context_id || ' ' || j.id || ' ' || j.parent_id);
    end loop;
    end loop;
    end;
    Additional informations:
    CONTEXT_CONTEXT.context_id references ALL_CONTEXTS.id
    CONTEXT_CONTEXT.id references ALL_CONTEXTS.id as well
    CONTEXT_CONTEXT.parent_id references ALL_CONTEXTS.id as well
    id is primary key of ALL_CONTEXTS
    (context_id, id) is primary key of CONTEXT_CONTEXT
    */

    user10047839 wrote:
    Unfortunately, the CONNECT_BY_ROOT is not supported by my version of the DB 9i.
    SELECT  context_id,
            SUBSTR(
                   SYS_CONNECT_BY_PATH(context_id,'/'),
                   2,
                   INSTR(
                         SYS_CONNECT_BY_PATH(context_id,'/') || '/',
                         1,
                         2
                        ) - 2
                  ) AS parent_context_id
      FROM  CONTEXT_CONTEXT
      START WITH parent_id IS NULL
        AND context_id IN (
                           SELECT  context_id
                             FROM  all_contexts
                             WHERE context_type IN ('MYTYPE')
      CONNECT BY PRIOR ID = parent_id
             AND context_id = PRIOR context_id;SY.

  • How can I convert output data (string?) from GPIB-read to an 1D array?

    Hello all,
    I am reading a displayed waveform from my Tektronix Oscilloscope (TDS3032) via the GPIB Read VI. The format of the waveform data is: positive integer data-point representation with the most significant byte transferred first (2 bytes per data point).
    The output data of GPIB-Read looks like a string(?) where the integer numbers and a sign like the euro-currency sign are seperated by spaces e.g. #5200004C3 4 4 4 4 3C3C3........ (C represents the euro-currency sign).
    How can I convert this waveform data into a 1D/2D array of real double floatingpoint numbers (DBL) so I can handle the waveform data for data-analysis?
    It would be very nice if someone know the solution for this.
    t
    hanks

    Hi,
    First of all, I'm assuming you are using LabVIEW.
    The first you need to do is parse the string returned by the instrument. In this case you need to search for the known symbols in the string (like the euro sign) and chop the string to get the numeric strings. Here are some examples on parsing from www.ni.com:
    Keyword Search: parsing
    Once you parse the numeric strings you can use the "String/number conversion VIs" in the String pallette.
    Hope this helps.
    DiegoF.Message Edited by Molly K on 02-18-2005 11:01 PM

  • How can we convert .mov ( implemented by quicktime APi)  to .WAV file

    Hi,
    How can we convert one .MOV audio file (generated by quicktime API) to .WAV audio file ( need LINER - encoding format).
    Here I dont know the encoding format of .MOV audio input file.
    regards,
    Rams

    mfrasyid1 wrote:
    I wonder why this happens? The "unable to handle.." really does come out twice. Is it because the inputfile.mov which I wanna convert comes from the merging oftwo wave files? If so, then how can I convert this into single wave file? Thank you.That is a weird message, but yes, the .mov file probably stored the 2 original WAV files as 2 tracks of data, rather than 1 track. So whenever it's trying to transcode to a WAV file, it fails to transcode both tracks.
    As for fixing it... I dunno. I know that JavaSound can mix two WAV files at the sample-level, so it actually mixes the sound instead of adding 2 tracks to a file...but I don't know why that's giving you those error messages, unless perhaps it's trying to transcode the video track into an audio track (perhaps the code isn't smart enough to handle transcoding a video file into an audio file? You'd have to check the code to see if that's the case...)

  • How can I convert video with srt subtitles?

    If I have an avi plus an .srt subtitles file, how can I convert this to play on the iPad?
    If, on my iMac, I use Quicktime, I can save the avi as .mov with hard subs.  But when I convert this .mov to mp4, the subtitles disappear.

    Why go to all the trouble of converting? Why not just download an app that can play .avi files with subtitle support?

  • How can I convert scanned docs into reconizable text?

    I have a very large PDF file of scanned documents the content of which is mostly text. How can I convert this into recognizable text so I could do a word search that would reveal results like a web search (speed wise)?

    Can the OCR apps convert preexisting PDF files on
    your system to text or do you have to scan directly
    into the OCR program at the time you do the original
    scan?
    You don't have to scan again. OCR apps can read from graphics files. If the OCR you pick can't use PDF, you can use Preview, or another application (e.g. Graphics Converter), to convert to a file format that the OCR can handle. All OCR apps should be able to handle TIFF. OmniPage Pro X can read both TIFF and PDF, but I wouldn't recommend it. It is overpriced, has no support, and is tricky to install on any OSX more recent than 10.1

  • When trying to convert quicktime mpg video files to m4v I am unable to open them or lose the audio completely. How can I fix this?

    So I am in nursing school and am making a group project that involves interviews of current RN's. I've been tasked with putting the video together from all the clips, even though I don't really have any experience with iMovie or iMovieHD (both of which I have on my MacBookPro). One of the interviews was recorded on what I think must have been some kind of Sony camera (I can find out if this is important), but I got the files off of a flash drive that my group member gave me. The files all opened in quicktime with no problem with complete audio and video, but when I tried to open it in either iMovie or iMovieHD it stated it could not "parse" the file (in HD) or just simply did not open (in regular iMovie). I'll have to learn the program either way but have been messing around with iMovieHD more so I would prefer to use this if I can. How can I convert the MPG files to m4v and still retain the audio part of the video? I've tried loading it into iPhoto and they won't load. Any suggestions would be greatly appreciated since I'm running out of time to put this video together! Thanks!!
    -Grace

    Hi Grace,
    The free app MPEG Streamclip may be able to convert the file to a more suitable format. It can be downloaded from the developer's site here:
    http://www.squared5.com/svideo/mpeg-streamclip-mac.html
    Here's a User Tip by AppleMan1958 that provides some more information about MPEG Streamclip (it's about importing homemade DVDs, but similar principles apply):
    https://discussions.apple.com/docs/DOC-3951
    John

  • I would like to convert my LPs to digital on my new mac book pro with retinal display . How can i do this?

    would like to convert my LPs to digital on my new mac book pro with retinal display
    . How can i do this?

    The new Mac's do not have analog audio in so you will have to go with a USB audio in device or else if you do not yet own a turntable (or are looking to upgrade) you could get a turntable that has USB out.
    The Griffin Technology iMic USB Audio Device is a low cost consumer grade solution if you already have a turntable.
    For recording I use Audacity: Free Audio Editor and Recorder which does a good job and has the ability to run the audio signal through various filters.

  • Each time I try to watch my itunes U podcast and try to skip forward my itunes freezes and gives me an error report and shuts off, this happens also when I try to convert it to my iPod. How can I fix this problem to be able to use the iTunes U?

    Each time I try to watch my iTunes U podcast and try to skip forward my iTunes freezes and gives me an error report and shuts off, this happens also when I try to convert the podcast to my iPod. How can I fix this problem to be able to use iTunes U?

    Hello, bisco,
    This forum is for questions from people who administer iTunes U sites. You'll be most likely to get help with this issue if you ask in the iTunes or iPod forums.
    Regards.

  • Ive got youtube videos converted to mp3 files on my itunes, they used to play fine but since the recent update they do not play correctly. how can i fix this?

    Ive got youtube videos converted to mp3 files on my itunes, they used to play fine but since the recent update they do not play correctly. how can i fix this?

    Try running these songs through MP3 Validator to see if there any issues.
    If nothing else, convert them to another format such as AAC via iTunes using the instructions in this Apple support document.
    iTunes: How to convert a song to a different file format
    B-rock

  • I have a Canon 6d and would like to convert my raw ( CR2) photo's into dng files. Adobe DNG converter 8.4 doesn't recognise the CR2 files. How can i solve this?

    i have a Canon 6d and would like to convert my raw ( CR2) photo's into dng files. Adobe DNG converter 8.4 doesn't recognise the CR2 files. How can i solve this?

    It is possible that you are not following instructions correctly in the DNG converter. The DNG converter interface asks for the FOLDER that contains your raw images. Choose the folder, but don't open it. After you have chosen the folder, click on the Convert button. The DNG conversion process should start.  Does that help you?

  • HT2729 I created a video on my iphone 4..sent it to my gmail and has mov format ..I am trying to convert it to wmv so I can incorporate it in my movie making software..am unable to convert..How can I do this?  I have tried several free download video conv

    I created a video on my IPHONE 4..emailed it to my gmail account and downloaded it..it was in mov format..I am trying to incorporate it in a movie making software, and as it does not accept mov files, I am trying to convert to wmv...How can I do this? I have downloaded some free video convertor software with no avail.

    There's no way to delete all message threads at one go. You can however do one contact thread at a time.
    In Messages app where you see a list of messages from different contacts,  tap Edit (top left), tap the red (on the left), then tap the red Delete button on the right.

  • Since installation of Mountain Lion the latest version of sony Image Data Converter doesn't work anymore. How can I tackle this problem?

    Since installation of Mountain Lion (10.8.2) the latest version of Sony Image Data Converter (Ver. 4.6) doesn't work anymore. How can I solve this problem?

    HI,
    I have seen this with AIM Logins that use the SSL Server and not the original server that was non SSL
    Since iChat 6 the server name has also changed as has the Login port (Although we were suggesting using the port 443).
    The AIM SSL server "Falls Over" more frequently than the other server.
    Also iChat/Messages reconnects automatically to the NON SSL server but not to the SSL one (It is a security risk)
    You had to manually Log out by Untick "Enable this Account" then Log back in again.
    I have not seen this happen in Jabber accounts but I don't use my computer the same way you  do.
    Jabber Servers tend to either use SSL or Not and can rarely login if you change to not using SLL.
    It also seems a bit strange that Disabling the account, as you phrase it, and re-enabling does not work.
    For Googletalk Logins try logging out then changing the port to 443 (Googletalk allows this port as well as 5223)
    Also check the Keychain (Applications/Utilities > Keychain Access)  and see if there is an issue with any Gmail or Googletalk certificate.
    10:35 PM      Wednesday; November 14, 2012
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
      iMac 2.5Ghz 5i 2011 (Mountain Lion 10.8.2)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

Maybe you are looking for

  • Where did the User Library folder go?

    I installed OSX 10.7 yesterday and was quite excited to do so, and by day two I am regretting it.  whether it is the uslessness of launchpad, to all of the old things i find missing.  One thing i just noticed was that i cant find is the User Library

  • Open Directory / Active Directory SSH access

    I have recently bound all of our web and database servers on our active directory and open directory realms. I am able to augment the AD records for my account and the accounts of the other admins, give them NFS home directories and all is great. We

  • Arabic language for E72

    hi i am from saudi arabiaand i did update my nokia phone last night (E72) BUT unlucky me i lost the arabic language option in my phone it gives me a lot of other languges but not arabic. please how can i restore my arabic lang. option because this is

  • Is it OK to connect the i-pod to the computer speakers???

    Can anyone tell me if it is alright to connect my 5th generation i-pod to the computer speakers as I don't have a sound system.My friend connected his i-pod mini to the PC speakers and it seems though as if it has damaged his earphones. IBM   Windows

  • My AE 6.5 won't load on laptop

    I've used AE 6.5 for years on my desktop and recently loaded it on my Acer desktop replacement laptop which also runs on XP and has loads of room and capacity for this program. However, when I click on the shortcut or exe to run the program, it start