I'm trying to create a program that displays the original document number and what changes have been made to it, when, where and by whom. I found a very helpful bit of code in thread: internal table but I've made certain modifications to it in order to fit our needs. Currently, the code looks the following:
DATA: I_CDHDR TYPE TABLE OF TY_CDHDR, I_CDPOS TYPE TABLE OF TY_CDPOS, I_FINAL TYPE TABLE OF TY_FINAL, W_CDHDR TYPE TY_CDHDR, W_CDPOS TYPE TY_CDPOS, W_FINAL TYPE TY_FINAL. PARAMETERS: P_OBJECT TYPE CDHDR-OBJECTCLAS, P_OBJID TYPE CDHDR-OBJECTID, P_UNAME TYPE CDHDR-USERNAME, P_UDATE TYPE CDHDR-UDATE, UTIME TYPE CDHDR-UTIME, TCODE TYPE CDHDR-TCODE, P_CHGIND TYPE CDHDR-CHANGE_IND, P_FNAME TYPE CDPOS-FNAME. SELECT OBJECTCLAS OBJECTID CHANGENR USERNAME UDATE UTIME TCODE ACT_CHNGNO CHANGE_IND FROM CDHDR INTO TABLE I_CDHDR WHERE OBJECTCLAS = P_OBJECT AND OBJECTID = P_OBJID. SELECT OBJECTCLAS OBJECTID FNAME VALUE_OLD VALUE_NEW FROM CDPOS INTO TABLE I_CDPOS FOR ALL ENTRIES IN I_CDHDR WHERE OBJECTCLAS = I_CDHDR-OBJECTCLAS AND OBJECTID = I_CDHDR-OBJECTID AND FNAME = P_FNAME. LOOP AT I_CDPOS INTO W_CDPOS. READ TABLE I_CDHDR INTO W_CDHDR WITH KEY OBJECTCLAS = CDPOS-OBJECTCLAS OBJECTID = CDPOS-OBJECTID. IF SY-SUBRC <> 0. WRITE: 'ERROR'. ELSEIF SY-SUBRC = 0. W_FINAL-CHANGENR = W_CDHDR-CHANGENR. W_FINAL-USERNAME = W_CDHDR-USERNAME. W_FINAL-UDATE = W_CDHDR-UDATE. W_FINAL-UTIME = W_CDHDR-UTIME. W_FINAL-TCODE = W_CDHDR-TCODE. W_FINAL-CHANGE_IND = W_CDHDR-CHANGE_IND. W_FINAL-FNAME = W_CDPOS-FNAME. W_FINAL-VALUE_OLD = W_CDPOS-VALUE_OLD. W_FINAL-VALUE_NEW = W_CDPOS-VALUE_NEW. WRITE: / W_FINAL-CHANGENR, W_FINAL-USERNAME, W_FINAL-UDATE, W_FINAL-UTIME, W_FINAL-TCODE, W_FINAL-CHANGE_IND, W_FINAL-FNAME, W_FINAL-VALUE_OLD, W_FINAL-VALUE_NEW. APPEND W_FINAL TO I_FINAL. ENDIF. ENDLOOP.
I believe something is not working in the READ TABLE- section of the code, because it only prints out ERROR. I would greately appreciate any input on this, I am extremely new to ABAP, so please let me know in case you need more information. Also, I did not paste the entire code. Have I missed something integral in the READ TABLE- statement?
Moderator Message: Keshav's posts indicate the question(s) are basic. Thread locked & points unassigned.
Edited by: Suhas Saha on Jan 4, 2012 5:49 PM