Unable to find out error

hi all
need help to solve this problem
In a file called AllBalancedOfSize.java write a method with the signature:
public void printBalanced(int len)
that uses recursion (either directly or indirectly) and prints all balanced strings, composed solely of the characters a and b of length len in lexical (dictionary) order. A balanced string is a string with an equal number of a and b characters. So, for example, abab is a balanced string and bbab is not a balanced string.
As an example, the call printBalanced(4) must print:
aabb
abab
abba
baab
baba
bbaa
A call printBalanced(5) must print nothing because there are no balanced strings of length 5 (same for any odd parameter value). A call printBalanced(0) must print an empty line because there is one balance string of length zero, the empty string! You may assume that len is always greater than or equal to zero.
i have done this
public class AllBalancedOfSize {
     public static void main(String[] args) {
          AllBalancedOfSize q4 = new AllBalancedOfSize();
          q4.printBalanced(4);
     public void printBalanced(int len) {
          if (len == 0) {
               System.out.println();
          } else {
               if (len % 2 == 0)
                    printBalanced(len, "");
     public void printBalanced(int len, String prefix) {
          if (len == 0) {
               int numofa = 0, numofb = 0;
               for (int i = 0; i <= prefix.length(); i++) {
                    char tmp = prefix.charAt(i);
                    if (tmp == 'a') {
                         numofa++;
                    } else {
                         numofb++;
               if (numofa == numofb) {
                    System.out.println(prefix);
          } else {
               printBalanced(len - 1, prefix + "a");
               printBalanced(len - 1, prefix + "b");
}but i got this from compiler
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 4
     at java.lang.String.charAt(String.java:687)
     at AllBalancedOfSize.printBalanced(AllBalancedOfSize.java:20)
     at AllBalancedOfSize.printBalanced(AllBalancedOfSize.java:31)
     at AllBalancedOfSize.printBalanced(AllBalancedOfSize.java:31)
     at AllBalancedOfSize.printBalanced(AllBalancedOfSize.java:31)
     at AllBalancedOfSize.printBalanced(AllBalancedOfSize.java:31)
     at AllBalancedOfSize.printBalanced(AllBalancedOfSize.java:12)
     at AllBalancedOfSize.main(AllBalancedOfSize.java:4)
need help to find out what is the error.
Edited by: dttl on May 10, 2009 11:44 AM

dttl wrote:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 4
     at java.lang.String.charAt(String.java:687)
need help to find out what is the error.When a String has a length of 4 characters, you can access them though indexes 0 through 3.
When a String has a length of N characters, you can access them though indexes 0 through N-1.

Similar Messages

  • CS2 Unable to find file errors

    Hi
    We are having trouble with photoshop cs2.  We can not open most files.  Tiff, PSD, some PDF files will give an "unable to find file error".  Jpg files, and certain PDF files and TIFF files that use jpg compression work.  I have tried resetting all the settings, changing scratch disks / memory usage, uninstalling all fonts, and reinstalling the application and the problem persists.
    Also i do not know if this is related but the same time we started having errors in photoshop we also have problems in Microsoft Word.  The font list shows a lot of fonts as just a white box.  Other apps can use the fonts fine.  Just not in word.
    I have attatched a JPG file with screen caps of the errors.

    I reset the options by doing the hold shift alt ctrl while starting up photoshop.  Also i deleted all the preference files out of the application data\adobe\photoshop folder.  Same problem persists.
    Also another issue i have noticed.  Say you perform an action like erasing somthing, or changing the brightness/contrast.  You can not see the changes until you click on a different tool.  Then it updates the display.
    I will try and locate the faq and see what it says.

  • HT4859 Last time I synced my IPad with my PC it migrated all my "Favorites" (about 100 folders) to the ICloud. I have searched and so far been unable to find out how to recover my "Favorites" list from the ICloud back to my PC. Any advice? Many thanks.

    Hi, Last time I synced my IPad with my PC, it (unknown to me) migrated all my PC "Favorites" (about 100 folders) to the ICloud.
    I have searched and so far been unable to find out how to recover my "Favorites" from the ICloud back to my PC. Any advice would
    be appreciated. Thank you.

    What did you do to get them synced to the Cloud.  Would that procedure help me get my favorites synced to my iPad2?

  • Pavilion g6 webcam. unable to find out how to launch it or turn it on. it does not show up anywhere

    Brand new lap top.  Unable to find out how to launch or use the webcam. It is not listed anywhere under control pannel.  Any ideas how to launch it?
    Thanks

    The software used to launch webcam is Cyberlink youcam installed on the Notebook. You can search for it in Start menu under All Programs.
    //Click on Kudos and Accept as Solution if my reply was helpful and answered your question//
    I am an HP employee!!

  • Help in finding out error in include ---se37

    Hello everyone,
    This is regarding the include in the function module .
    Where we define constants , i have to define like this
    If plant EQ 'ita' OR plant EQ 'del' OR plant EQ 'net' .
            c_form LIKE itcta-tdform VALUE 'form1' .
            ELSE .
            c_form LIKE itcta-tdform VALUE 'form2' .
            ENDIF .
    The error that i get while activating is "unable to interpret PLANT -possible causes -incorrect spelling or comma error".
    I am not able to find out where i am going wrong .
    Can anyone help me find out the error or where and what i missed out .
    Any help will be appreciated .
    Thanks
    Sumit

    Hi,
    U have not defined the varibale PLANt.
    Defin ethe same in   Tcode = SE37
    Give the function module name and clcik on change.
    Use menu GOTO----
    >GLOBAL DATA.  define the plant here as below.
    data: plant type werks.
    Regards,
    Pravin

  • "Unable to check out" error message in CS4

    I have InDesign CS4, but do not have InCopy. When I exported an InDesign CS4 file to CS3 interchange format, and then tried to edit the orginal file, I got an error message saying: "Unable to check out this file. It may be in use by someone else." From reading the documentation, it appears that I inadvertently engaged a feature of InCopy, but when  I go to the Edit->InCopy menu, the option to check the file back in is greyed out. How do I check the file back in so that I can edit it?

    I've just experienced the same error message in CS4. I got rid of it by going to the Links panel, selecting all the links to Incopy, and Unlinking.

  • How to find out error segments in a group of Idocs

    Hi,
    1. For every 5 minutes Idocs are coming in to R3 from some third party systems, and this scenerio some of the Idocs are in failed status as well.
    My doubt is how to see the all segments at a time, since there might be some problem with the data, so I need to check the each and every segment all time.  Is there any way to findout all segments at a time for the group of the idocs of the same message type.
    2. How to find out the error in segments of the idoc.
    Many thanks in advance.
    Thanks.
    Ahmed.

    Hi Mujeeb Ahmed 
    I dont have SAP System in front. Any way check the menu bar, there you can fine SEGMENT WITH ERROR OPTION
    Regards
    Kumar

  • Unable to find out asdm image file cisco asa

    Hello,
    i am using cisco asa in gns 3 simulator ,unable find out the ASDM image or .bin file in
    ASA flash .If not how can i
    Uploade the ASDM image onto the ASA flash.
    Please help me out

    Follow this:
    http://www.xerunetworks.com/2012/03/asa-84-asdm-on-gns3-step-by-step-guide/
    For Networking Posts check my blog at http://laguiadelnetworking.com/
    Cheers,
    Julio Carvajal Segura

  • Source for finding out error codes PB 17"

    I ran hardware test and it returned an error code of:
    21 SS / 1 / 5 : 0 x 42 (5)
    and it was at the logic board test section...
    Anyone know this code, or how I can find out what it is?

    Google shows one result for this error code without the "(5)" and it seems to have indicated a sound-related problem.
    In any event, when AHT shows errors, you really are best advised to take the machine in to have it looked at.
    Good luck.

  • [SOLVED] linux-lts GRUB "Unable to find device" error

    I installed linux-lts, reconfigured GRUB, and created an initial ramdisk env,
    # pacman -S linux-lts
    # grub-mkconfig -o /boot/grub/grub.cfg
    # mkinitcpio -p linux-lts
    I'm able to load the linux-lts kernel from rEFInd (dual booting with MacOS), but I get the error:
    Warning: /lib/modules/3.14.17-1-lts/modules.devname not found - ignoring
    ERROR: device "UUID=df842c36-41f7-4606-b219-7879cf1c4825" not found
    ERROR: Unable to find root device "UUID=df842c36-41f7-4606-b219-7879cf1c4825"
    and am dropped into  a recovery shell.
    However,
    % ll /lib/modules/3.14.17-1-lts/modules.devname ~
    -rw-r--r-- 1 root root 411 Aug 26 13:20 /lib/modules/3.14.17-1-lts/modules.devname
    so at least the file exists.
    Here's the specific lines from grub.cfg pertaining to linux-lts :
    # grep linux-lts /boot/grub/grub.cfg
    linux /boot/vmlinuz-linux-lts root=UUID=df842c36-41f7-4606-b219-7879cf1c4825 rw quiet systemd.show_status=0
    initrd /boot/initramfs-linux-lts.img
    menuentry 'Arch Linux, with Linux linux-lts' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-lts-advanced-df842c36-41f7-4606-b219-7879cf1c4825' {
    echo 'Loading Linux linux-lts ...'
    linux /boot/vmlinuz-linux-lts root=UUID=df842c36-41f7-4606-b219-7879cf1c4825 rw quiet systemd.show_status=0
    initrd /boot/initramfs-linux-lts.img
    menuentry 'Arch Linux, with Linux linux-lts (fallback initramfs)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-lts-fallback-df842c36-41f7-4606-b219-7879cf1c4825' {
    echo 'Loading Linux linux-lts ...'
    linux /boot/vmlinuz-linux-lts root=UUID=df842c36-41f7-4606-b219-7879cf1c4825 rw quiet systemd.show_status=0
    initrd /boot/initramfs-linux-lts-fallback.img
    and here is the complete grub.cfg
    ### BEGIN /etc/grub.d/00_header ###
    insmod part_gpt
    insmod part_msdos
    if [ -s $prefix/grubenv ]; then
    load_env
    fi
    if [ "${next_entry}" ] ; then
    set default="${next_entry}"
    set next_entry=
    save_env next_entry
    set boot_once=true
    else
    set default="0"
    fi
    if [ x"${feature_menuentry_id}" = xy ]; then
    menuentry_id_option="--id"
    else
    menuentry_id_option=""
    fi
    export menuentry_id_option
    if [ "${prev_saved_entry}" ]; then
    set saved_entry="${prev_saved_entry}"
    save_env saved_entry
    set prev_saved_entry=
    save_env prev_saved_entry
    set boot_once=true
    fi
    function savedefault {
    if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
    fi
    function load_video {
    if [ x$feature_all_video_module = xy ]; then
    insmod all_video
    else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
    fi
    if [ x$feature_default_font_path = xy ] ; then
    font=unicode
    else
    insmod part_gpt
    insmod ext2
    set root='hd0,gpt4'
    if [ x$feature_platform_search_hint = xy ]; then
    search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 df842c36-41f7-4606-b219-7879cf1c4825
    else
    search --no-floppy --fs-uuid --set=root df842c36-41f7-4606-b219-7879cf1c4825
    fi
    font="/usr/share/grub/unicode.pf2"
    fi
    if loadfont $font ; then
    set gfxmode=auto
    load_video
    insmod gfxterm
    fi
    terminal_input console
    terminal_output gfxterm
    if [ x$feature_timeout_style = xy ] ; then
    set timeout_style=menu
    set timeout=5
    # Fallback normal timeout code in case the timeout_style feature is
    # unavailable.
    else
    set timeout=5
    fi
    ### END /etc/grub.d/00_header ###
    ### BEGIN /etc/grub.d/10_linux ###
    menuentry 'Arch Linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-df842c36-41f7-4606-b219-7879cf1c4825' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_gpt
    insmod ext2
    set root='hd0,gpt4'
    if [ x$feature_platform_search_hint = xy ]; then
    search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 df842c36-41f7-4606-b219-7879cf1c4825
    else
    search --no-floppy --fs-uuid --set=root df842c36-41f7-4606-b219-7879cf1c4825
    fi
    echo 'Loading Linux linux-lts ...'
    linux /boot/vmlinuz-linux-lts root=UUID=df842c36-41f7-4606-b219-7879cf1c4825 rw quiet systemd.show_status=0
    echo 'Loading initial ramdisk ...'
    initrd /boot/initramfs-linux-lts.img
    submenu 'Advanced options for Arch Linux' $menuentry_id_option 'gnulinux-advanced-df842c36-41f7-4606-b219-7879cf1c4825' {
    menuentry 'Arch Linux, with Linux linux-lts' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-lts-advanced-df842c36-41f7-4606-b219-7879cf1c4825' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_gpt
    insmod ext2
    set root='hd0,gpt4'
    if [ x$feature_platform_search_hint = xy ]; then
    search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 df842c36-41f7-4606-b219-7879cf1c4825
    else
    search --no-floppy --fs-uuid --set=root df842c36-41f7-4606-b219-7879cf1c4825
    fi
    echo 'Loading Linux linux-lts ...'
    linux /boot/vmlinuz-linux-lts root=UUID=df842c36-41f7-4606-b219-7879cf1c4825 rw quiet systemd.show_status=0
    echo 'Loading initial ramdisk ...'
    initrd /boot/initramfs-linux-lts.img
    menuentry 'Arch Linux, with Linux linux-lts (fallback initramfs)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-lts-fallback-df842c36-41f7-4606-b219-7879cf1c4825' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_gpt
    insmod ext2
    set root='hd0,gpt4'
    if [ x$feature_platform_search_hint = xy ]; then
    search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 df842c36-41f7-4606-b219-7879cf1c4825
    else
    search --no-floppy --fs-uuid --set=root df842c36-41f7-4606-b219-7879cf1c4825
    fi
    echo 'Loading Linux linux-lts ...'
    linux /boot/vmlinuz-linux-lts root=UUID=df842c36-41f7-4606-b219-7879cf1c4825 rw quiet systemd.show_status=0
    echo 'Loading initial ramdisk ...'
    initrd /boot/initramfs-linux-lts-fallback.img
    menuentry 'Arch Linux, with Linux linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-advanced-df842c36-41f7-4606-b219-7879cf1c4825' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_gpt
    insmod ext2
    set root='hd0,gpt4'
    if [ x$feature_platform_search_hint = xy ]; then
    search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 df842c36-41f7-4606-b219-7879cf1c4825
    else
    search --no-floppy --fs-uuid --set=root df842c36-41f7-4606-b219-7879cf1c4825
    fi
    echo 'Loading Linux linux ...'
    linux /boot/vmlinuz-linux root=UUID=df842c36-41f7-4606-b219-7879cf1c4825 rw quiet systemd.show_status=0
    echo 'Loading initial ramdisk ...'
    initrd /boot/initramfs-linux.img
    menuentry 'Arch Linux, with Linux linux (fallback initramfs)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-fallback-df842c36-41f7-4606-b219-7879cf1c4825' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_gpt
    insmod ext2
    set root='hd0,gpt4'
    if [ x$feature_platform_search_hint = xy ]; then
    search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 df842c36-41f7-4606-b219-7879cf1c4825
    else
    search --no-floppy --fs-uuid --set=root df842c36-41f7-4606-b219-7879cf1c4825
    fi
    echo 'Loading Linux linux ...'
    linux /boot/vmlinuz-linux root=UUID=df842c36-41f7-4606-b219-7879cf1c4825 rw quiet systemd.show_status=0
    echo 'Loading initial ramdisk ...'
    initrd /boot/initramfs-linux-fallback.img
    ### END /etc/grub.d/10_linux ###
    ### BEGIN /etc/grub.d/20_linux_xen ###
    ### END /etc/grub.d/20_linux_xen ###
    ### BEGIN /etc/grub.d/30_os-prober ###
    ### END /etc/grub.d/30_os-prober ###
    ### BEGIN /etc/grub.d/40_custom ###
    # This file provides an easy way to add custom menu entries. Simply type the
    # menu entries you want to add after this comment. Be careful not to change
    # the 'exec tail' line above.
    ### END /etc/grub.d/40_custom ###
    ### BEGIN /etc/grub.d/41_custom ###
    if [ -f ${config_directory}/custom.cfg ]; then
    source ${config_directory}/custom.cfg
    elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
    source $prefix/custom.cfg;
    fi
    ### END /etc/grub.d/41_custom ###
    ### BEGIN /etc/grub.d/60_memtest86+ ###
    ### END /etc/grub.d/60_memtest86+ ###
    and fstab:
    % cat /etc/fstab ~
    # /etc/fstab: static file system information
    # <file system> <dir> <type> <options> <dump> <pass>
    # /dev/sda4
    UUID=df842c36-41f7-4606-b219-7879cf1c4825 / ext4 rw,relatime,data=ordered 0 1
    # /dev/sda5
    UUID=0a37147c-f87b-4c2c-9b2d-75c852568c4b /home ext4 rw,relatime,data=ordered 0 2
    Found a few things about 30 things on the net, this,  but by my reckoning, it is not similar enough / I don't understand the solution enough to be comfortable applying it to my set up.   Tried that, it didn't work.  Seems like every issue that manifests itself in this way (esp in dual boot situations) has a different solution, ranging from blacklisting certain modules  in /etc/default/grub to reording the block and autodetect hooks in mkinitcpio.conf.
    Any help troubleshooting this would be greatly appreciated.
    Also, here is mkinitcpio.conf (sans comments):
    # vim:set ft=sh
    # MODULES
    MODULES=""
    # BINARIES
    BINARIES=""
    # FILES
    FILES=""
    # HOOKS
    HOOKS="base udev block autodetect modconf filesystems keyboard fsck usbinput"
    Last edited by oktorok (2014-11-04 02:29:08)

    Is the root filesystem encrypted by default?   I would like to try a solution like adding
    cryptdevice=device:dmname
    to my /etc/default/grub but I don't know what to put for dmname.  It seems like the wiki suggests stating it verbatum,
    dmname is the device-mapper name given to the device after decryption, which will be available as /dev/mapper/dmname.
    I tried
    GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda4:/dev/mapper/dmname"
    without success.  This solution doesn't make sense if the filesystem is not encrypted. 
    I don't really think this applies, but I can't understand why the modules.devname would not be found when it plainly exists exactly where the system is looking for it.
    In the meantime I'm trying
    sudo mkinitcpio -k 3.14.17-1-lts -g /boot/initramfs-linux-lts.img -S autodetect
    to set up the initial ram env, per this thread.
    [update] the above method, referenced in the link, did not fix the issue.
    Last edited by oktorok (2014-08-28 22:24:43)

  • Unable to find resource error after transport

    Hello,
    there is a strange error happening with some mapping after transporting the content of some namespaces from Dev to Q using file (client) export import.
    We already tried the scenario successul on Q, but after some reimports of changes (which still work on Dev) we get the following error in the "request message mapping" step:
    "RESOURCE_NOT_FOUIND"
    Unable to find resource .............. in the following software component versions: ........
    However the mapping is there and can be tested. Any idea on this?

    But last time one day later the scenario was running fine. Could that really be a problem with cache update?
    If all the required objects are present in the QA environment and are active....then yes it can be a problem with the Cache.
    I hope that no error was encountered (or import was done properly) during the import/ reimport.
    Regards,
    Abhishek.

  • Jdeveloper remote debugging - Unable to find source error message

    Hi,
    I am trying to remote debug a simple Java application (non-web) using Jdeveloper. The Jdev debugger can connect to the remote debuggee, but unfortunately it throws me a message saying: 'Unable to find source file'. As a result, if I ignore this message, it simply ignores my source breakpoints.
    Can anybody please help with any tips?
    My project source is checked out from CVS and does not follow a conventional source path as such.
    Thanks,
    Neil.

    The warranty entitles you to complimentary phone support for the first 90 days of ownership.

  • How do u find out error in procedure

    Hi,
    I have procedure that 10000 lines of codes.How do i find out the error in the procedure.And again i have a package there is 10 procedure and 20 funcction
    there are 2000 lines or more of code in each procedure and function.How do i find out the error in which procdure or function .One more question in about procedure .i have a procedure that contain 2000 lines of code when i execute a procedure at the time it will take time 30 minute.but i want to execute the procedure in less time .what are those step plz help me.
    thanks

    "How do i find out the error in the procedure"
    Do you refer to compilation error or runtime errors...????
    For compilation errors , you can write "show errors" after the try of package creation....
    For runtime errors... - assuming you call one - by -one the most if not all the routines in this package - you can execute the first(main) routine which calls the second , and then the third ... e.t.c. . When the runtime error occurs , the routine / line of it will be displayed.....
    If the above is not true (the packaged routines are not called , at least most of them ) you should add exception portions in your code and messages in them (dbms_output.put_line)...
    Greetings...
    Sim

  • My Master server is stopping automatically unable to find out the issue

    Dear Experts,
    My Master server in CMC is stopping automatically and is going to infinite stop state.when i again restart manually its connecting but again it is stopping.what may be the cause unable to find the solution
    Thanks in Advance,
    Regards,
    Vinay.G

    Go to the Tomcat site and read the "First Web App" docs. I'm sure you didn't deploy your servlet properly.
    %

  • Please try to find out error in this program

    Hi abapers,
      when i execute this report , i got the error. please anybody find the error "Runtime Errors         GETWA_NOT_ASSIGNED"
    Short text
        Field symbol has not yet been assigned." this error i got..
    please help me..
    REPORT  ZBLOCKED_ALV_CLS.
    *Data Objects to avoid tables work area.
    DATA: V_KUNNR TYPE KNA1-KUNNR,
          V_LIFNR TYPE LFA1-LIFNR.
    *Logiv to maintain frist block.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
      SELECT-OPTIONS: CUSTOMER FOR V_KUNNR.
    SELECTION-SCREEN END OF BLOCK B1.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
      SELECT-OPTIONS: VENDOR FOR V_LIFNR.
    SELECTION-SCREEN END OF BLOCK B2.
    TYPES: BEGIN OF TY_VBAK,
           VBELN TYPE VBELN_VA,
           ERDAT TYPE ERDAT,
           END OF TY_VBAK.
    TYPES: BEGIN OF TY_EKKO,
           EBELN TYPE EBELN,
           AEDAT TYPE ERDAT,
           END OF TY_EKKO.
    DATA: WA_VBAK TYPE TY_VBAK,
          WA_EKKO TYPE TY_EKKO,
          I_VBAK TYPE STANDARD TABLE OF TY_VBAK,
          I_EKKO TYPE STANDARD TABLE OF TY_EKKO.
    TYPE-POOLS: SLIS.
    DATA: REPID TYPE SY-REPID.
    DATA: LAYOUT TYPE SLIS_LAYOUT_ALV,
          FCAT TYPE SLIS_FIELDCAT_ALV,
      F_VBAK LIKE STANDARD TABLE OF FCAT,
      F_EKKO LIKE STANDARD TABLE OF FCAT,
      I_EVENTS TYPE SLIS_T_EVENT.
    START-OF-SELECTION.
    REPID = SY-REPID.
    * REPID TYPE SY-REPID.
    PERFORM: GET_DATA,
             COL_HEAD.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
      EXPORTING
        I_CALLBACK_PROGRAM             = SY-REPID.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
      EXPORTING
        IS_LAYOUT                        = LAYOUT
        IT_FIELDCAT                      = F_VBAK
        I_TABNAME                        = 'I_VBAK'
        IT_EVENTS                        = I_EVENTS
    *   IT_SORT                          =
    *   I_TEXT                           = ' '
      TABLES
        T_OUTTAB                         = I_VBAK
    * EXCEPTIONS
    *   PROGRAM_ERROR                    = 1
    *   MAXIMUM_OF_APPENDS_REACHED       = 2
    *   OTHERS                           = 3
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
      EXPORTING
        IS_LAYOUT                        = LAYOUT
        IT_FIELDCAT                      = F_EKKO
        I_TABNAME                        = 'I_EKKO'
        IT_EVENTS                        = I_EVENTS
    *   IT_SORT                          =
    *   I_TEXT                           = ' '
      TABLES
        T_OUTTAB                         = I_EKKO
    * EXCEPTIONS
    *   PROGRAM_ERROR                    = 1
    *   MAXIMUM_OF_APPENDS_REACHED       = 2
    *   OTHERS                           = 3
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
    *&      Form  GET_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM GET_DATA .
    SELECT VBELN ERDAT FROM VBAK INTO TABLE I_VBAK WHERE KUNNR IN CUSTOMER.
      SELECT EBELN AEDAT FROM EKKO INTO TABLE I_EKKO WHERE LIFNR IN VENDOR.
    ENDFORM.                    " GET_DATA
    *&      Form  COL_HEAD
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM COL_HEAD .
    PERFORM BUILD_CAT USING:
          'VBELN' 'VBAK' 'VBELN' 'I_VBAK' 'SD',
          'ERDAT' 'VBAK' 'ERDAT' 'I_VBAK' 'SD',
          'EBELN' 'EKKO' 'EBELN' 'I_EKKO' 'MM',
          'AEDAT' 'EKKO' 'AEDAT' 'I_EKKO' 'MM'.
    ENDFORM.                    " COL_HEAD
    *&      Form  BUILD_CAT
    *       text
    *      -->P_0238   text
    *      -->P_0239   text
    *      -->P_0240   text
    *      -->P_0241   text
    *      -->P_0242   text
    FORM BUILD_CAT  USING    VALUE(P_0238)
                             VALUE(P_0239)
                             VALUE(P_0240)
                             VALUE(P_0241)
                             VALUE(P_0242).
      CLEAR FCAT.
      IF P_0242 = 'SD'.
        FCAT-REF_FIELDNAME = P_0238.
        FCAT-REF_TABNAME = P_0239.
        FCAT-FIELDNAME = P_0240.
        FCAT-TABNAME = P_0241.
        APPEND FCAT TO F_VBAK.
    ENDIF.
    IF P_0242 = 'MM'.
        FCAT-REF_FIELDNAME = P_0238.
        FCAT-REF_TABNAME = P_0239.
        FCAT-FIELDNAME = P_0240.
        FCAT-TABNAME = P_0241.
        APPEND FCAT TO F_VBAK.
    ENDIF.
    ENDFORM.                    " BUILD_CAT
    Thanks,
    Vinay.
    Edited by: abapvinay on Apr 19, 2011 4:56 AM

    Hi,
    You have passed as shown below :
    IF p_0242 = 'SD'.
        fcat-ref_fieldname = p_0238.
        fcat-ref_tabname = p_0239.
        fcat-fieldname = p_0240.
        fcat-tabname = p_0241.
        APPEND fcat TO f_vbak.
      ENDIF.
      IF p_0242 = 'MM'.
        fcat-ref_fieldname = p_0238.
        fcat-ref_tabname = p_0239.
        fcat-fieldname = p_0240.
        fcat-tabname = p_0241.
        APPEND fcat TO f_vbak. " Change this to F_EKKO
      ENDIF.
    Hope this helps
    Regards,
    Madhukar Shetty

Maybe you are looking for

  • Error 199 and dead programs after multiple updates

    Yesterday I applied the 2-2007 security-for-Panther, java for 10.3, DST for Panther, and Office 2004 updates to my dual-boot G4 while booted into 10.3.9. (The G4 can also boot into 9.2.2...a good thing since there are programs requiring OS9 that I co

  • How do I detect if the mouse button is down, outside of the applet?

    Using X = MouseInfo.getPointerInfo().getLocation().x; Y = MouseInfo.getPointerInfo().getLocation().y;I can detect the mouse location anywhere on the entire screen, but after an extensive search on Google I cannot find any way to detect whether a mous

  • Regd: SALERT_CREATE

    Hi @, I am using SALERT_CREATE for the alert purpose where I am making Lookup for the same in UDF and the send alert . Now i observed that the particular RFC is present in both R/3 and XI when I am making look up in r/3 I am not getting any result .W

  • In-ear headphones buzzing

    I got some new in-ear headphones a little bit ago. The right ear has this buzzing/crackling sound. Is there any way to fix it or get a replacement pair?

  • ODI 11.1.1.5 Installation is failing in HP UX

    Hi All, ODI 11.1.1.5 Installation is failing due to below error. OS: HP UX 11.3i Itanium system JDK 6 Error: /usr/lib/dld.sl: Can't find path for shared library: libjli.sl /usr/lib/dld.sl: No such file or directory [HP ARIES32]: Error occured while w