Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Need help with this dynamic internal table

Former Member
0 Likes
571

Hi to all experts,

my requirement is to display the locked records in infotype . The infotype is given in the selection screen . Depending upon the infotype selected i need populate some fields to the final internal table to display in alv.my problem is how to get the infotype fields at runtime

here is my code

REPORT  zhrr0014 NO STANDARD PAGE HEADING.


INFOTYPES : 0002,
            0006,
            0007,
            0008,
            0014,
            0015,
            0021,
            0032,
            0185,
            0267.

TABLES: pernr.

TYPES: BEGIN OF ty_final,
           pernr  TYPE pernr-pernr,
           cname  TYPE p0002-cname,
           inftyp TYPE infty,
           begda  TYPE sy-datum,
           endda  TYPE sy-datum,
           uname  TYPE aenam,
           aedtm  TYPE aedtm,
      END OF ty_final.

DATA:gt_final TYPE STANDARD TABLE OF ty_final,
     gs_final LIKE LINE OF gt_final.


DATA: w_name TYPE cname .

CONSTANTS: c_one TYPE c VALUE '1'.

INITIALIZATION.

  pnp-sw-ignorelockedrecords = 'N'.


  SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
  PARAMETERS :p_inftyp TYPE p0000-infty.
  SELECTION-SCREEN END OF BLOCK b1.





START-OF-SELECTION .

GET pernr.

  PERFORM update_report.
*&---------------------------------------------------------------------*
*&      Form  UPDATE_REPORT
*&---------------------------------------------------------------------*

FORM update_report .

  

  *rp_provide_from_last *p_infty* space pn-begda pn-endda."*contains the infotype no like 0002,0006 (some infotypes)

  IF pnp-sw-found NE c_one .
    REJECT.
  ENDIF.
 
 
 

  gs_final-pernr = p0002-pernr.   

  w_name = p0002-cname.

  gs_final-cname  = p0002-cname.

  gs_final-inftyp  = '0002'.

  gs_final-begda = p0002-begda.

  gs_final-endda = p0002-endda.

  gs_final-uname = p0002-uname.

  gs_final-aedtm = p0002-aedtm. 

  APPEND gs_final TO gt_final.   " gt_final is the final internal table 

  CLEAR gs_final.



ENDFORM.                    " UPDATE_REPORT

i know this can be done in dynamic programming and getting any idea .  Please help me out 

thanks in advance

Edited by: mohammed abdul hai on Oct 13, 2009 10:36 AM

Edited by: mohammed abdul hai on Oct 13, 2009 10:37 AM

Edited by: mohammed abdul hai on Oct 13, 2009 10:39 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
488

hi abadul,

use field symbols to achieve this..

search 'dynamic internal table' in SDN.

Hi to all experts,

my requirement is to display the locked records in infotype . The infotype is given in the selection screen . Depending upon the infotype selected i need populate some fields to the final internal table to display in alv.my problem is how to get the infotype fields at runtime

here is my code

REPORT  zhrr0014 NO STANDARD PAGE HEADING.


INFOTYPES : 0002,
            0006,
            0007,
            0008,
            0014,
            0015,
            0021,
            0032,
            0185,
            0267.

TABLES: pernr.

TYPES: BEGIN OF ty_final,
           pernr  TYPE pernr-pernr,
           cname  TYPE p0002-cname,
           inftyp TYPE infty,
           begda  TYPE sy-datum,
           endda  TYPE sy-datum,
           uname  TYPE aenam,
           aedtm  TYPE aedtm,
      END OF ty_final.

DATA:gt_final TYPE STANDARD TABLE OF ty_final,
     gs_final LIKE LINE OF gt_final.


DATA: w_name TYPE cname .

CONSTANTS: c_one TYPE c VALUE '1'.

INITIALIZATION.

  pnp-sw-ignorelockedrecords = 'N'.


  SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
  PARAMETERS :p_inftyp TYPE p0000-infty.
  SELECTION-SCREEN END OF BLOCK b1.





START-OF-SELECTION .

GET pernr.

  PERFORM update_report.
*&---------------------------------------------------------------------*
*&      Form  UPDATE_REPORT
*&---------------------------------------------------------------------*

FORM update_report .

  

  *rp_provide_from_last *p_infty* space pn-begda pn-endda."*contains the infotype no like 0002,0006 (some infotypes)

  IF pnp-sw-found NE c_one .
    REJECT.
  ENDIF.
 
 
 

  gs_final-pernr = p0002-pernr.   

  w_name = p0002-cname.

  gs_final-cname  = p0002-cname.

  gs_final-inftyp  = '0002'.

  gs_final-begda = p0002-begda.

  gs_final-endda = p0002-endda.

  gs_final-uname = p0002-uname.

  gs_final-aedtm = p0002-aedtm. 

  APPEND gs_final TO gt_final.   " gt_final is the final internal table 

  CLEAR gs_final.



ENDFORM.                    " UPDATE_REPORT

i know this can be done in dynamic programming and getting any idea .  Please help me out 

thanks in advance

Edited by: mohammed abdul hai on Oct 13, 2009 10:36 AM

Edited by: mohammed abdul hai on Oct 13, 2009 10:37 AM

Edited by: mohammed abdul hai on Oct 13, 2009 10:39 AM

3 REPLIES 3
Read only

Former Member
0 Likes
489

hi abadul,

use field symbols to achieve this..

search 'dynamic internal table' in SDN.

Read only

0 Likes
488

DATA: w_tabname TYPE tabname.

field-symbols: <infty> TYPE any TABLE.

CONCATENATE 'P' p_inftyp INTO w_tabname.

ASSIGN (w_tabname) TO <infty>.

rp_provide_from_last <infty> space pn-begda pn-endda.

IF pnp-sw-found NE c_one .

REJECT.

ENDIF.

i tried like getting error that <infty> is a table without a header line

Read only

Former Member
0 Likes
488

Hai

Have a look on given below link[;