How to fix a bug in Rich Heilman's weblog code?

Dear all,
I'm trying to create a report on a code given in the weblog by Rich Heilman:
/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap
Unfortunately, there is a bug in the code and a short dump occurs:
A RAISE statement in the program "CL_ABAP_TYPEDESCR=============CP" raised the
exception condition "TYPE_NOT_FOUND".
I copied here the whole code:
REPORT  Z_DYNAMIC.
type-pools : abap.
field-symbols: <dyn_table> type standard table,
               <dyn_wa>,
               <dyn_field>.
data: dy_table type ref to data,
      dy_line  type ref to data,
      xfc type lvc_s_fcat,
      ifc type lvc_t_fcat.
selection-screen begin of block b1 with frame.
parameters: p_table(30) type c default 'T001'.
selection-screen end of block b1.
start-of-selection.
  perform get_structure.
  perform create_dynamic_itab.
  perform get_data.
  perform write_out.
form get_structure.
data : idetails type abap_compdescr_tab,
       xdetails type abap_compdescr.
data : ref_table_des type ref to cl_abap_structdescr.
* Get the structure of the table.
  ref_table_des ?=
      cl_abap_typedescr=>describe_by_name( p_table ).
  idetails[] = ref_table_des->components[].
  loop at idetails into xdetails.
    clear xfc.
    xfc-fieldname = xdetails-name .
    xfc-datatype = xdetails-type_kind.
    xfc-intlen = xdetails-length.
    xfc-decimals = xdetails-decimals.
    append xfc to ifc.
  endloop.
endform.
form create_dynamic_itab.
* Create dynamic internal table and assign to FS
  call method cl_alv_table_create=>create_dynamic_table
               exporting
                  it_fieldcatalog = ifc
               importing
                  ep_table        = dy_table.
  assign dy_table->* to <dyn_table>.
* Create dynamic work area and assign to FS
  create data dy_line like line of <dyn_table>.
  assign dy_line->* to <dyn_wa>.
endform.
form get_data.
* Select Data from table.
  select * into table <dyn_table>
             from (p_table).
endform.
form write_out.
* Write out data from table.
  loop at <dyn_table> into <dyn_wa>.
    do.
      assign component  sy-index
         of structure <dyn_wa> to <dyn_field>.
      if sy-subrc <> 0.
        exit.
      endif.
      if sy-index = 1.
        write:/ <dyn_field>.
      else.
        write: <dyn_field>.
      endif.
    enddo.
  endloop.
endform.
Could someone fix a bug, please?
Best regards,
Eugene

Hi Eugene,
I made a small change to the code and it works even for MARA. See the code below..
REPORT zsritest58 .
TYPE-POOLS : abap.
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
               <dyn_wa>,
               <dyn_field>.
DATA: dy_table TYPE REF TO data,
      dy_line  TYPE REF TO data,
      xfc TYPE lvc_s_fcat,
      ifc TYPE lvc_t_fcat.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: p_table(30) TYPE c DEFAULT 'T001'.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
  PERFORM get_structure.
  PERFORM create_dynamic_itab.
  PERFORM get_data.
  PERFORM write_out.
*       FORM get_structure                                            *
FORM get_structure.
<b>*data : idetails type abap_compdescr_tab,
*       xdetails type abap_compdescr.
*data : ref_table_des type ref to cl_abap_structdescr.
** Get the structure of the table.
*  ref_table_des ?=
*      cl_abap_typedescr=>describe_by_name( p_table ).
*  idetails[] = ref_table_des->components[].
*  loop at idetails into xdetails.
*    clear xfc.
*    xfc-fieldname = xdetails-name .
*    xfc-datatype = xdetails-type_kind.
*    xfc-intlen = xdetails-length.
*    xfc-decimals = xdetails-decimals.
*    append xfc to ifc.
*  endloop.
  SELECT SINGLE tabname INTO p_table FROM dd02l
  WHERE tabname EQ p_table
    AND as4local EQ 'A'
    AND as4vers EQ '0000'.
  IF sy-subrc NE 0.
    STOP.
  ENDIF.
  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
   EXPORTING
*   I_BUFFER_ACTIVE              =
     i_structure_name             = p_table
*   I_CLIENT_NEVER_DISPLAY       = 'X'
*   I_BYPASSING_BUFFER           =
    CHANGING
      ct_fieldcat                  = ifc[]
   EXCEPTIONS
     inconsistent_interface       = 1
     program_error                = 2
     OTHERS                       = 3.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.</b>
ENDFORM.
*       FORM create_dynamic_itab                                      *
FORM create_dynamic_itab.
* Create dynamic internal table and assign to FS
  CALL METHOD cl_alv_table_create=>create_dynamic_table
               EXPORTING
                  it_fieldcatalog = ifc
               IMPORTING
                  ep_table        = dy_table.
  ASSIGN dy_table->* TO <dyn_table>.
* Create dynamic work area and assign to FS
  CREATE DATA dy_line LIKE LINE OF <dyn_table>.
  ASSIGN dy_line->* TO <dyn_wa>.
ENDFORM.
*       FORM get_data                                                 *
FORM get_data.
* Select Data from table.
  SELECT * INTO CORRESPONDING FIELDS OF TABLE <dyn_table>
             FROM (p_table).
ENDFORM.
*       FORM write_out                                                *
FORM write_out.
* Write out data from table.
  LOOP AT <dyn_table> INTO <dyn_wa>.
    DO.
      ASSIGN COMPONENT  sy-index
         OF STRUCTURE <dyn_wa> TO <dyn_field>.
      IF sy-subrc <> 0.
        EXIT.
      ENDIF.
      IF sy-index = 1.
        WRITE:/ <dyn_field>.
      ELSE.
        WRITE: <dyn_field>.
      ENDIF.
    ENDDO.
  ENDLOOP.
ENDFORM.
Hope this helps..
Sri

Similar Messages

  • On 27th and 28th marchb2013 , I pad calendar, (showing March), opens then immediately closes. I cannot get into thebCalendar to change anything, (previous bug involved having all-da events on April 1st. How to fix this bug?

    Does anyone know how to fix this bug?
    Thanks,
    Peter, Worcs.UK

    I followed your instructions and installed Developer Suite 10G on Windows Vista Home Premium edition. I have Oracle 11G DB running on the same machine.
    Two points, Steve:
    1. When I tried to set the maximum virtual memory to 6110 an error message displayed from Windows and told me that I can't set the maximum virtual memory to more than 4096. I set it to 4090 and it worked and I got nothing wrong during the installation process.
    2. After installing JInitiator and disabling Java on Firefox I called the http://127.0.0.1:8889/forms/frmservlet page and everything seemed to be OK because the Oracle Forms Services logo appeared and then a successful installation message appeared , but as I clicked (ok) to continue a gray screen appeared inside the browser (like the one displayed when you try to run a Java applet inside a browser) and then I wait to death till something appears but sadly nothing. I just get a blank gray screen inside my Firefox browser.
    Do you have any idea what to do to solve the problem?
    Regards

  • How to fix a bug after updating to 5.1.1 version for apple tv?

    How to fix a bug after updating to 5.1.1 version for apple tv?
    It stopped working freezing in the initial screen....
    Ihad alreadt tried to disconect the cables, the control everithing...

    How to fix a bug after updating to 5.1.1 version for apple tv?
    It stopped working freezing in the initial screen....
    Ihad alreadt tried to disconect the cables, the control everithing...

  • Slide to unlock doesn't work happend more than 8 time every time i had to restart my phone, Please can you tell me how to fix this bug . iPhone 5, iOS 7.0.4

    Slide to unlock doesn't work happend more than 8 time every time i had to restart my phone, Please can you tell me how to fix this bug .
    iPhone 5, iOS 7.0.4

    Backup and restore your software via iTunes. If the problem continues, restore as a NEW device. If this solves it, that means there is some corruption in your backup file. If the problem is still there, you should take it to the Genius Bar at an Apple Store for evaluation.

  • My YouTube crashed in my iPad how to fix the bug

    My YouTube crashed in my iPad how to fix the bug

    If there's a bug with YouTube, the YouTube developers would have to fix it. You cannot fix other people's apps.
    Try re-loafing the YouTube app - it may have been a temporary glitch.

  • How about fixing the bug report submission page ?

    I've been trying for I think the 11 time to submit a bugreport to bugreport.sun.com and each time,
    the submission FAIL. And of course you loose everything you entered in the page.
    Email to the address specified when it fail also FAIL.
    rejected by the server for the recipient domain sun.comby userp1020.oracle.com. [156.151.31.79].
    The error that the other server returned was:
    550 5.1.1 <[email protected]>... User unknown
    Please Fix, a bug report page that can't even submit simple text its ridiculous.
    This is not the first time I have difficulties getting your site to work.

    You're complaining to the wrong people.
    Re: bug database does not work?
    OTN forum admin are not responsible for the java bug reporting.  They cannot fix what isn't theirs.
    Locking this thread

  • How to fix the bug ,

    hi friends
    i have raised ora-00600 to support
    they have issued following solution
    to fix the bug i am not able understand the doc can some one help me or guide me to do this issue
    thanks for help
    You seem to be hitting Bug 9373370 The wrong cursor may be executed by JDBC thin following a query timeout / ORA-3137 [12333]
    To resolve this issue the fix for bug 9373370 must be applied to the database and the fix for bug 9967872 to the JDBC driver.

    user1175505 wrote:
    hi friends
    i have raised ora-00600 to support
    they have issued following solution
    to fix the bug i am not able understand the doc can some one help me or guide me to do this issue
    thanks for help
    You seem to be hitting Bug 9373370 The wrong cursor may be executed by JDBC thin following a query timeout / ORA-3137 [12333]
    To resolve this issue the fix for bug 9373370 must be applied to the database and the fix for bug 9967872 to the JDBC driver.
    Please have a look in this documents ID in My Oracle Support Website:
    - Bug 9373370 - The wrong cursor may be executed by JDBC thin following a query timeout / ORA-3137 [12333] (Doc ID 9373370.8)

  • HT5313 How about fixing the bugs in iCal? and Sleep Mode?

    The 10.7.5 update sure has a lot of fluff patches. When is Apple going to fix something important, like all the bugs in iCal? And the bugs in Sleep Mode?
    Examples:
    • iCal events tend to pop up 30+ minutes late all day if I sleep the computer overnight. This has been going on since 10.3.9.
    • Network Issues: iChat sessions via Bonjour have to be manually restarted after coming out of sleep.
    • Disks mounted over the network dismount during sleep.
    • Screen Saver doesn't play well with other apps: I lock the screen when I'm away from my desk. If Firefox starts using all available CPU time while the screen saver is on, screen saver won't exit. This can make it very difficult to get control of the machine.
    How about a patch for the above?
    I'm a professional software engineer, so spare me the Blame The Customer tactics.

    PS. Best Example:
    • Last week I almost missed an appointment because iCal decided I wanted to be alerted to this event 9 hours after it happened. ... Maybe you think I typed it into iCal wrong. So what if I did? WHO THE #@$! WANTS AN ALERT *AFTER* AN EVENT HAPPENS? Why is it even an option?

  • How to fix the bug of JDK1.3?

    i installed Tomcat 3.2.3 as Windows NT service successfully. but when i logged out and logged in again, the tomcat service stopped! you know, i've set the service as auto-start. so i used jdk1.2.2 instead of jdk1.3, and it worked well.
    but i still want to use jdk1.3. how to solve the problem? i haven't tried it with jdk1.4 or tomcat4.0. i wonder whether tomcat4.0 can work with IIS.
    btw, i cannot understand the bug report on http://developer.java.sun.com/developer/bugParade/bugs/4323062.html well. can you help me out?
    thanks so much!
    freeado

    What you need to do is use JDK 1.3.1 instead, which has a fix for this issue. Then, add the flag -Xrs to your command line to stop it being terminated by logoff.

  • How to fix aggregate bug?

    I have an aggregate bug and would like to know how I can solve the problem. Data Modeler looses the column name of a view, which makes it impossible to create another view on top of the broken view. Here is a screen shot of the problem:
    http://public.ceving.de/2012070500/Oracle_SQL_Developer_Data_Modeler-Aggregate_Bug.png
    The second column of VIEW_1 has no name anymore!
    The bug can be reproduces by creating a simple table containing two integers. After that create the following view:
    SELECT TABLE_1.Column_1,
    MAX(TABLE_1.Column_2) AS Max_Column_2
    FROM TABLE_1
    GROUP BY TABLE_1.Column_1
    And now try to create a new view with the query builder using the already created view.

    Thanks, I logged bug for that.
    Philip

  • How to fix a bug(?) in iCal/Calendar/Reminders?

    The iCal/Calendar (fox OS X 8)/Reminders (OS X 8) app has this very annoying bug It's quite minor but it's quite confusing sometimes. Whenever I try to add a new event, the window that appears that will let me set the date, time, etc. always has 2011 (xx/xx/11) for the year. For example, if I want to set the event for July 29, 2012 ("07/29/12"), it still shows "07/29/11". I've been having this problem ever since I was on the iCal app on OS X Lion but now that I've just upgraded to Mountain Lion, the problem's still there with the Calendar as well as the Reminders app.
    Please refer to the screenshot I included. You can see that I chose July 29, 2012 as the date for the Sample Event. But the date that shows on the "from" field is still 07/29/11. I don't know I they intended it to be like this but it is very confusing.
    PS: The same goes if I add an event before 2011. If I, for example, add an event on July 29, 2010, it still shows "07/29/11".

    The iCal/Calendar (fox OS X 8)/Reminders (OS X 8) app has this very annoying bug It's quite minor but it's quite confusing sometimes. Whenever I try to add a new event, the window that appears that will let me set the date, time, etc. always has 2011 (xx/xx/11) for the year. For example, if I want to set the event for July 29, 2012 ("07/29/12"), it still shows "07/29/11". I've been having this problem ever since I was on the iCal app on OS X Lion but now that I've just upgraded to Mountain Lion, the problem's still there with the Calendar as well as the Reminders app.
    Please refer to the screenshot I included. You can see that I chose July 29, 2012 as the date for the Sample Event. But the date that shows on the "from" field is still 07/29/11. I don't know I they intended it to be like this but it is very confusing.
    PS: The same goes if I add an event before 2011. If I, for example, add an event on July 29, 2010, it still shows "07/29/11".

  • How to fix camera bug on Samsung Galaxy S5?

    Camera stops working on Samsung Galaxy S5 and cannot view all photos in gallery.  The photos look like they will load but never do.  When try to use camera it is really slow and it will eventually tell me that the camera has stopped working.  Restarting provides only a temporary fix.

    Hi,
    The issue started probably 2 months ago, but as I had not used very much I
    can't recall the exact time that it started and what apps were
    updated/installed at that time.  I went through and uninstalled a bunch of
    apps in hopes of fixing it.   I have also noticed in the past week the lock
    screen that I have will sometimes display funky characters instead of
    numbers and letters.  Restarting only seems to provide a temporary fix.
    Build Number: LRX21T.G900VVRU1BOC4.
    Thanks,
    Samantha
    On Fri, May 1, 2015 at 6:05 PM, Verizon Wireless Customer Support <

  • TS4268 I downloaded the new iOS7 version and I am unable to use my phone properly now.  Any ideas on how to fix the bugs?

    My text messaging, facetime and calling features are not working?  Any help would be great.

    Hi superally9!
    I have an article here that I believe might describe your issue and will help you with some troubleshooting steps:
    iOS: Wi-Fi settings grayed out or dim
    http://support.apple.com/kb/ts1559
    Thanks for using the Apple Support Communities!
    Cheers,
    Braden

  • I lost my phone and use the IPHone locater, Now that i got my phone back it is disabled and I don't know how to fix it. It had asked for a code but I have no idea what it is so I tried several things but to no avail

    I lost my phone and used the iphone locater to find it. Now that it has been returned to me, it is disabled and says connect to ITUNES. Can you help me ?

    Does the link below help?
    Forgot passcode for your iPhone, iPad, or iPod touch, or your device is disabled - Apple Support

  • [svn:fx-trunk] 6433: Fix a bug where the display object sharing code in GraphicElement assumes that that drawnDisplayObject is a Sprite , when it could be any display object (in this case a flash.media.Video).

    Revision: 6433
    Author:   [email protected]
    Date:     2009-04-30 12:55:29 -0700 (Thu, 30 Apr 2009)
    Log Message:

    Revision: 6433
    Author:   [email protected]
    Date:     2009-04-30 12:55:29 -0700 (Thu, 30 Apr 2009)
    Log Message:

Maybe you are looking for

  • What type of DVD should I use for Windows Backup?

    I am wanting to do my Windows Backup and I was wondering what type of DVD media I should use. Is it better to use a RW or only R type DVD. I have an HP Omni 220-1180qd, A5W89AV#ABA, running Win7 64 bit. I thought I read it can use CD's, DVD's but I w

  • Installing Os 10 on new hard drive

    How do i install a fresh copy of mac OS 10.. on a new hard drive.. I have the Tiger cd's. I really need to get my mac back up n running. Message was edited by: ChinyBwoy

  • Best solution for customers to edit InDesign files within a browser????

    I have done a lot of research of some of the companies out there now that do this (one2edit, wealledit, chilli publishing, etc.) and none are really what we are looking for.  To begin, we are a publishing company that produces custom academic plannin

  • Basic Database

    I am new to cold fusion and have been practicing with some basic SQL on a database. I have it working locally but when I run it on my web host it doesn't work. They are telling me the issues are coding issues (probablly right) but I cant find them. I

  • I am unable to have my password reset on acrobat on my mini  iPad HD

    Is there upgrade, or guide, manual for instructions?