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

add a field to structure from program

Former Member
0 Likes
1,189

Hi Folks,

I have a structure - ZSDT_SO_BACKLOG_DCRESTR having some fields.

My data declaration -

DATA lt_data_out  TYPE zsdt_so_backlog_dcrestr.
DATA ls_data_out  TYPE LINE OF zsdt_so_backlog_dcrestr.

I need to add one more field into internal table LT_DATA_OUT without inserting that inside structure - ZSDT_SO_BACKLOG_DCRESTR.

In the below code LV_COMBU is the field. My output is ALV and my final internal table is LT_DATA_OUT.

LOOP AT lt_data_out INTO ls_data_out.     
       READ TABLE lt_hier INTO ls_hier WITH KEY prctr = wa_marc-prctr.
       IF sy-subrc = 0.
         MOVE ls_hier-level3 TO lv_combu.
       ENDIF.
   ENDLOOP.

How to put LV_COMBU inside LT_DATA_OUT.

Thanks for your help.

Babu

1 ACCEPTED SOLUTION
Read only

PeterJonker
Active Contributor
0 Likes
1,160

Types: begin of ty_data_out.

include type zsdt_so_backlog_dcrestr.

types: lv_combu type combu,

end of ty_data_out.

data: ls_data_out type ty_data_out.

Hi Folks,

I have a structure - ZSDT_SO_BACKLOG_DCRESTR having some fields.

My data declaration -

DATA lt_data_out  TYPE zsdt_so_backlog_dcrestr.
DATA ls_data_out  TYPE LINE OF zsdt_so_backlog_dcrestr.

I need to add one more field into internal table LT_DATA_OUT without inserting that inside structure - ZSDT_SO_BACKLOG_DCRESTR.

In the below code LV_COMBU is the field. My output is ALV and my final internal table is LT_DATA_OUT.

LOOP AT lt_data_out INTO ls_data_out.     
       READ TABLE lt_hier INTO ls_hier WITH KEY prctr = wa_marc-prctr.
       IF sy-subrc = 0.
         MOVE ls_hier-level3 TO lv_combu.
       ENDIF.
   ENDLOOP.

How to put LV_COMBU inside LT_DATA_OUT.

Thanks for your help.

Babu

3 REPLIES 3
Read only

PeterJonker
Active Contributor
0 Likes
1,161

Types: begin of ty_data_out.

include type zsdt_so_backlog_dcrestr.

types: lv_combu type combu,

end of ty_data_out.

data: ls_data_out type ty_data_out.

Read only

0 Likes
1,160

Hi Peter ,

Thanks for your reply.

My issue now is -


TYPES : BEGIN OF ty_final.
        INCLUDE TYPE zsd_so_backlog_dcrestr.
TYPESlv_combu TYPE setnamenew,
        END OF ty_final.

DATA: lt_data_out TYPE STANDARD TABLE OF ty_final,
      ls_data_out  TYPE ty_final.


CALL FUNCTION 'ZSD_BACKLOG_DCRESTR'
    EXPORTING
      im_kunag      = rt_kunag
      im_kunwe      = rt_kunwe
      im_vbeln      = rt_vbeln
      im_ppgi        = rt_wadat
      im_matnr      = rt_matnr
      im_auart      = rt_auart
    IMPORTING
      dcrestr        = lt_data_out
      batch_detr_log = lt_batch_log.


LOOP AT lt_data_out INTO ls_data_out.
       READ TABLE lt_hier INTO ls_hier WITH KEY prctr = wa_marc-prctr.
       IF sy-subrc = 0.
         MOVE ls_hier-level3 TO lv_combu.
       ENDIF.
       APPEND ls_data_out TO lt_data_out.
   ENDLOOP.

Type conflict error.

Read only

0 Likes
1,160

You need to declare two table

Data: lt_data_out type zsdt_so_backlog_dcrestr,  " for the function module

           ls_data_out type zsd_so_backlog_dcrestr,

          lt_final type standard table of ty_final,   "final table for alv output

          ls_final type ty_final.

  1. CALL FUNCTION 'ZSD_BACKLOG_DCRESTR' 
  2.     EXPORTING 
  3.       im_kunag      = rt_kunag 
  4.       im_kunwe      = rt_kunwe 
  5.       im_vbeln      = rt_vbeln 
  6.       im_ppgi        = rt_wadat 
  7.       im_matnr      = rt_matnr 
  8.       im_auart      = rt_auart 
  9.     IMPORTING 
  10.       dcrestr        = lt_data_out 
  11.       batch_detr_log = lt_batch_log. 
  12. LOOP AT lt_data_out INTO ls_data_out. 
  13.        READ TABLE lt_hier INTO ls_hier WITH KEY prctr = wa_marc-prctr. 
  14.        IF sy-subrc = 0
  15.            move-corresponding ls_data_out to ls_final.
  16.             ls_fina-lv_combu = ls_hier-level3.
  17.  
  18.        ENDIF. 
  19.        APPEND ls_final TO lt_final. 
  20. clear: ls_data_out, ls_final.
  21.    ENDLOOP. 

  22. That should do the trick.