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

fetching the data without any key field common

Former Member
0 Likes
2,524

i have scenario like this.in which i want to have DDTEXT from DD02T...hoping to get responses..

for this i need to fetch all the entries from the table konh using the knumh field.

then concatenate it_konh-kvewe and it_konh-kotabnr into the variable(a tablename).

then,fetch data from DD02T using this variable and choosing the TABNAME = A914.

like this i will get DDTEXT.

here is expecting your inputs so as to have a start on ..

thnks in adv!!

Please suggest ....am i doing correctly..

my final internal table being itab and description will come from DDTEXT that will be populated into l_text through fieldcatalog.

kindly reply what is to be added asi am not able to execute the report.

data:l_kvewe type konh-kvewe,

l_kotabnr type konh-kotabnr,

l_new type c,

l_ddtext type DD02T-ddtext.

loop at itab.

IF not i_konh is initial.

select knumh

kvewe

kotabnr

from konh

into corresponding fields of table i_konh

where kvewe = l_kvewe

and kotabnr = l_kotabnr.

concatenate l_kvewe l_kotabnr into l_new.

if sy-subrc = 0.

select single TABNAME

DDTEXT

from dd02t

into itab

where ddtext = itab-l_ddtext.

l_ddtext = l_new.

endif.

endif.

append itab.

endloop.

11 REPLIES 11
Read only

Former Member
0 Likes
2,433

Hi,

I would like to know what you want to pull from DD02T, as DDTEXT contains the table description,

in different language, when pulling the data from codition table what you want to show in the output. not clear please brief it. with points as on requirement sheet.

Read only

0 Likes
2,433

will clear it again.

i just wish to display in the output of the report is a text which should come from DDTEXT field of DD02T table.

This DDTEXT should be populated using the two fields kvewe and kotabnr from KONH table.

i need to concatenate these two kvewe and kotabnr into one varialbe and pass it to DDTEXT for display.

Read only

0 Likes
2,433

Here is the code , But really i am not understanding why u want to display the table descrpiton on the output .

Any way below is the code for your requirment.

Concatenate wa_konh-kvewe wa_konh-kotabnr into v_table.

Select *

from dd02t

table into it_display_table

where TABLENAME = v_table.

it will display all language text for the table.

Loop at it_display_table.

write : / ......

endloop.

I hope the information helps.

Cheers

Joginder

Read only

0 Likes
2,433

Please suggest ....am i doing correctly..

my final internal table being itab and description will come from DDTEXT that will be populated into l_text through fieldcatalog.

kindly reply what is to be added asi am not able to execute the report.

data:l_kvewe type konh-kvewe,

l_kotabnr type konh-kotabnr,

l_new type c,

l_ddtext type DD02T-ddtext.

loop at itab.

IF not i_konh is initial.

select knumh

kvewe

kotabnr

from konh

into corresponding fields of table i_konh

where kvewe = l_kvewe

and kotabnr = l_kotabnr.

concatenate l_kvewe l_kotabnr into l_new.

if sy-subrc = 0.

select single TABNAME

DDTEXT

from dd02t

into itab

where ddtext = itab-l_ddtext.

l_ddtext = l_new.

endif.

endif.

append itab.

endloop.

Read only

0 Likes
2,433

FORM collect_data .

loop at i_vbak .

clear : itab , t_vbpa .

itab-kunnr = i_vbak-kunnr .

itab-vbeln = i_vbak-vbeln .

itab-vkorg = i_vbak-vkorg .

itab-spart = i_vbak-spart .

itab-vtweg = i_vbak-vtweg .

itab-ernam = i_vbak-ernam .

itab-knumv = i_vbak-knumv .

select single name1 into itab-name1 from kna1

where kunnr = itab-kunnr .

select single * from vbpa into t_vbpa

where vbeln = itab-vbeln .

select single zregion2 into itab-zregion2 from zbwcntry

where land1 = t_vbpa-land1.

loop at i_vbap where vbeln = i_vbak-vbeln .

itab-posnr = i_vbap-posnr .

itab-matnr = i_vbap-matnr .

select single maktx into itab-maktx

from makt

where matnr = i_vbap-matnr .

read table itemp with key vbeln1 = i_vbap-vbeln.

if sy-subrc = 0 .

loop at i_cdhdr where objectid = itemp-vbeln .

itab-username = i_cdhdr-username .

itab-udate = i_cdhdr-udate .

itab-utime = i_cdhdr-utime .

*Start of Change by Tanisha on 19/12/08

read table i_cdpos with key OBJECTCLAS = i_cdhdr-OBJECTCLAS

OBJECTID = i_cdhdr-OBJECTID

CHANGENR = i_cdhdr-CHANGENR

FNAME = 'WAERS'.

if sy-subrc = 0 .

if i_cdpos-tabkey+0(6) = i_vbap-posnr .

itab-CURKY_NEW = i_cdpos-value_new .

itab-CURKY_OLD = i_cdpos-value_old .

itab-kschl = i_cdpos-tabkey+11(4).

clear i_cdpos.

endif.

endif.

read table i_cdpos with key OBJECTCLAS = i_cdhdr-OBJECTCLAS

OBJECTID = i_cdhdr-OBJECTID

CHANGENR = i_cdhdr-CHANGENR

FNAME = 'KBETR'.

if sy-subrc = 0 .

if i_cdpos-tabkey+0(6) = i_vbap-posnr .

itab-AMT_NEW = i_cdpos-value_new .

itab-AMT_OLD = i_cdpos-value_old .

itab-kschl = i_cdpos-tabkey+11(4).

clear i_cdpos.

endif .

endif.

read table i_cdpos with key OBJECTCLAS = i_cdhdr-OBJECTCLAS

OBJECTID = i_cdhdr-OBJECTID

CHANGENR = i_cdhdr-CHANGENR

FNAME = 'KMEIN'.

if sy-subrc = 0 .

if i_cdpos-tabkey+0(6) = i_vbap-posnr .

itab-UOM_NEW = i_cdpos-value_new .

itab-UOM_OLD = i_cdpos-value_old .

itab-kschl = i_cdpos-tabkey+11(4).

ITAB-UOMC = 'Y'.

clear i_cdpos.

endif.

endif.

read table i_cdpos with key OBJECTCLAS = i_cdhdr-OBJECTCLAS

OBJECTID = i_cdhdr-OBJECTID

CHANGENR = i_cdhdr-CHANGENR

FNAME = 'KPEIN'.

if sy-subrc = 0 .

if i_cdpos-tabkey+0(6) = i_vbap-posnr .

itab-PER_NEW = i_cdpos-value_new .

itab-PER_OLD = i_cdpos-value_old .

itab-kschl = i_cdpos-tabkey+11(4).

clear i_cdpos.

endif .

endif.

if itab-kschl eq 'PR00 ' or itab-kschl eq 'ZPRK' or

itab-kschl eq 'ZPRD' or itab-kschl eq 'ZPRF' or

itab-kschl eq 'ZPRB' or itab-kschl eq 'ZTAR'.

shift itab-vbeln left deleting leading '0'.

*End of Change by Tanisha on 19/12/08

append itab .

*Start of Change by Tanisha on 19/12/08

*endif.

*endif.

*End of Change by Tanisha on 19/12/08

endif .

endloop .

endif .

endloop .

endloop .

loop at i_vbak .

read table itab with key vbeln = i_vbak-vbeln .

if sy-subrc ne 0 .

clear itab .

itab-knumv = i_vbak-knumv .

itab-kunnr = i_vbak-kunnr .

itab-vbeln = i_vbak-vbeln .

itab-vkorg = i_vbak-vkorg .

itab-spart = i_vbak-spart .

itab-vtweg = i_vbak-vtweg .

itab-ernam = i_vbak-ernam .

itab-username = i_vbak-ernam.

select single name1 into itab-name1 from kna1

where kunnr = itab-kunnr .

select single * from vbpa into t_vbpa

where vbeln = itab-vbeln .

select single zregion2 into itab-zregion2 from zbwcntry

where land1 = t_vbpa-land1.

loop at i_vbap where vbeln = i_vbak-vbeln .

itab-posnr = i_vbap-posnr .

itab-matnr = i_vbap-matnr .

select single maktx into itab-maktx

from makt

where matnr = i_vbap-matnr .

loop at i_zprice where vbeln = i_vbak-vbeln

and posnr = i_vbap-posnr .

if i_zprice-kschl = 'PR00'.

itab-AMT_new = i_zprice-amount .

itab-kschl = 'PR00'.

itab-AMT_old = i_zprice-amount_old.

itab-CURKY_old = i_zprice-waers .

itab-CURKY_new = i_zprice-waers_new .

itab-utime = i_zprice-crtime .

itab-udate = i_zprice-crdate .

endif .

if i_zprice-kschl = 'ZPRK'.

itab-AMT_new = i_zprice-amount .

itab-kschl = 'ZPRK'.

itab-AMT_old = i_zprice-amount_old.

itab-curky_old = i_zprice-waers .

itab-curky_new = i_zprice-waers_new .

itab-utime = i_zprice-crtime .

itab-udate = i_zprice-crdate .

endif .

if i_zprice-kschl = 'ZPRF'.

itab-amt_new = i_zprice-amount .

itab-kschl = 'ZPRF'.

itab-amt_old = i_zprice-amount_old.

itab-curky_old = i_zprice-waers .

itab-curky_new = i_zprice-waers_new .

itab-utime = i_zprice-crtime .

itab-udate = i_zprice-crdate .

endif .

if i_zprice-kschl = 'ZPRD'.

itab-amt_new = i_zprice-amount .

itab-kschl = 'ZPRD'.

itab-amt_old = i_zprice-amount_old.

itab-curky_old = i_zprice-waers .

itab-curky_new = i_zprice-waers_new .

itab-utime = i_zprice-crtime .

itab-udate = i_zprice-crdate .

endif .

shift itab-vbeln left deleting leading '0'.

append itab .

endloop .

endloop .

endif .

endloop .

loop at itab.

if itab-kschl in s_kschl .

else .

delete itab index sy-tabix .

endif .

if itab-amt_old eq ' ' and itab-amt_new eq ' '.

delete itab index sy-tabix .

endif .

endloop .

if not itab[] is initial .

select * from konv into corresponding fields of table

i_konv for all entries in itab

where knumv = itab-knumv

and kposn = itab-posnr

and kschl = itab-kschl .

endif .

loop at itab .

t_tabix = sy-tabix .

read table i_konv with key knumv = itab-knumv

kposn = itab-posnr

kschl = itab-kschl .

if sy-subrc = 0 .

if i_konv-kherk = 'A' or

i_konv-kherk = 'C' .

itab-uom_old = i_konv-kmein .

itab-kherk = i_konv-kherk.

else .

itab-uom_old = i_konv-kmein.

itab-kherk = 'X'. .

endif .

IF itab-amt_new IS NOT INITIAL AND itab-amt_old IS NOT INITIAL.

IF itab-amt_new GT itab-amt_old .

itab-chg = 'H'.

ELSE.

itab-chg = 'L'.

ENDIF.

ELSE.

itab-chg = ' '.

ENDIF.

if itab-amt_new NE itab-amt_old.

itab-RPRI = 'Y'.

endif.

IF itab-curky_old NE itab-curky_new.

itab-CCID = 'Y'.

ENDIF.

if itab-uom_old NE itab-uom_new.

itab-UOMC = 'Y'.

endif.

if itab-per_old NE itab-per_new.

itab-PUC = 'Y'.

endif.

****Start of Change by Tanisha on 19/12/2008

data:l_kvewe type konh-kvewe,

l_kotabnr type konh-kotabnr,

l_new type c,

l_ddtext type DD02T-ddtext.

IF not i_konh is initial.

select knumh

kvewe

kotabnr

from konh

into corresponding fields of table i_konh

where kvewe = l_kvewe

and kotabnr = l_kotabnr.

concatenate l_kvewe l_kotabnr into l_new.

if sy-subrc = 0.

select single TABNAME

DDTEXT

from dd02t

into itab

where ddtext = itab-l_ddtext.

l_ddtext = l_new.

endif.

endif.

append itab.

****End of Change by Tanisha on 19/12/2008

Modify itab index t_tabix .

endif .

endloop .

ENDFORM. " collect_data

Read only

0 Likes
2,433

Hi

The code which you have been written is not appropriate from performance point of view and also you have used itab multiple loops which can be done in one loop of itab. Any way i will re-write the code and sent you when i am back in office 2morrow.

Cheers

Joginder

Read only

joginder_singh
Active Participant
0 Likes
2,433

Hi

Can you elaborate the requirement .I am just confused why u required the table destricption .

What i am assuming is you want to get the table name dynamically and then select the data from that table dynamically .

In that case you can use the below code ,I may be wrong in understanding your question.


* Get the Acess Sequence number based on the Condition Types
* Entered on Selection Screen
  select kappl
         kschl
         kozgf
    from t685
    into table t_t685
   where kvewe eq c_kvewe
     and kappl eq c_kappl
     and kschl in s_kschl .

  if not t_t685[] is initial.
* When an entry found fetch the condtion tables based on the
* Acess Sequence number which is being fetched

    sort t_t685 by kozgf.

    select kappl
           kozgf
           kolnr
           kotabnr
      from t682i
      into table t_t682i
       for all entries in t_t685
     where kvewe eq c_kvewe
       and kappl eq c_kappl
       and kozgf eq t_t685-kozgf.

    if sy-subrc eq 0.
      sort t_t682i by kotabnr.
      select kotabnr
             kotab
        from t681
        into table t_t681
         for all entries in t_t682i
       where kvewe   eq c_kvewe
         and kotabnr eq t_t682i-kotabnr
         and kappl   eq c_kappl.

      loop at t_t681 into st_t681.

* For a Table found get the Field names using the Function
* Module

        call function 'RV_TABLE_READ'
             exporting
                  tr_table        = st_t681-kotab
             tables
                  dd03v_tab       = t_dd03v
                  dd04v_tab       = t_dd04v
                  dfies_tab       = t_dfies
             exceptions
                  table_not_found = 1
                  others          = 2.

        if sy-subrc eq 0.

          r_fieldname-sign    = 'I'.
          r_fieldname-option = 'EQ'.

          loop at t_dd03v.

* Create Field Catalog for the Fields as We need to create
* dynamic table to fetch the entries from found table

            clear st_fieldcat.
            st_fieldcat-fieldname = t_dd03v-fieldname.
            st_fieldcat-datatype  = t_dd03v-datatype.
            st_fieldcat-inttype   = t_dd03v-inttype.
            st_fieldcat-intlen    = t_dd03v-intlen.

            append st_fieldcat to t_fieldcat.


            r_fieldname-low = t_dd03v-fieldname.
            append r_fieldname.

          endloop.

* To create a Dynamic table for the fieldcatalog t_fieldcat

          call method cl_alv_table_create=>create_dynamic_table
                    exporting
                       it_fieldcatalog = t_fieldcat
                    importing
                       ep_table        = t_table.

* Assign the created dynamic tabel to Field symbol.

          assign t_table->* to <fs_table>.

          create data st_line like line of <fs_table>.
          assign st_line->* to <fs_struc>.

* Fetch the entries from the table found based on the
* condition type, sales organization ,distribution channel
* and the date entered on the selection screen.

          select *
            from (st_t681-kotab)
            into table <fs_table>
           where kappl  eq c_kappl
             and kschl  in s_kschl
             and vkorg  eq p_vkorg
             and vtweg  in s_vtweg
             and datbi  gt p_date
             and datab  lt p_date.

* When an entries found Fill the t_cond table with the entries found.

          loop at <fs_table> into <fs_struc>.

            st_cond-kappl = c_kappl.

* To assign the value for the corresponding field
            perform assign_field:

            using text-001  changing st_cond-kschl,
            using text-002  changing st_cond-vkorg,
            using text-003  changing st_cond-vtweg,
            using text-004  changing st_cond-konda,
            using text-005  changing st_cond-kondm,
            using text-006  changing st_cond-matnr,
            using text-007  changing st_cond-datbi,
            using text-008  changing st_cond-datab,
            using text-009  changing st_cond-knumh,
            using text-010  changing st_cond-kunnr.

            if not st_cond-matnr is initial .
* This Purpose of the flag to use when an fetching
* the entries from Mara
              w_mat_found = 'X'.

            endif.

            if not st_cond-kunnr is initial.
* This Purpose of the flag to use when an fetching
* the entries from KNA1
              w_cust_found = 'X'.

            endif.
            append st_cond to t_cond.
            clear st_cond.

          endloop.

          refresh : t_dd03v,
                    t_fieldcat,
                    r_fieldname.

          unassign :<fs_table>,
                    <fs_struc>.

          clear: t_table,
                 st_fieldcat.

        endif.
      endloop.

    endif.
  endif.

*&---------------------------------------------------------------------*
*&      Form  assign_field
*&---------------------------------------------------------------------*
*  * To assign the value for the corresponding field
*----------------------------------------------------------------------*
*      -->P_TEXT  fielname
*      <--P_COND  value of the field
*----------------------------------------------------------------------*
form assign_field using    p_field type any
                  changing p_cond type any .

  if p_field in r_fieldname.
* When a field is present in the range which is created based on
* the fields in the table

    assign component p_field of structure <fs_struc> to <fs_field>.
    p_cond = <fs_field>.
    unassign <fs_field>.

  endif.
endform.

Code Formatted by: Alvaro Tejada Galindo on Dec 23, 2008 11:08 AM

Read only

Former Member
0 Likes
2,433

again making the requirements more clear..

i just wish to display in the output of the report is a text which should come from DDTEXT field of DD02T table.

This DDTEXT should be populated using the two fields kvewe and kotabnr from KONH table.

i need to concatenate these two kvewe and kotabnr into one varialbe and pass it to DDTEXT for display.

kindly help.

Read only

0 Likes
2,433

Hi

See the Modified code.You need to create some Workareas and Internat table which i have used in the below code such as

wa_kna1,it_kna1,it_vbak_temp,it_vbpa,wa_vbpa,it_zbwcntry,wa_zbwcntry. May be some more check the code.

I hope you can imrpve the performance by using the below code. and avoiding unnecssary multiple loops on itab.

FORM collect_data .

if not i_vbak[] is initial.

i_vbak_temp[] = i_vbak[].

sort i_vbak_temp.

delete adjacent duplicates from i_vbak_temp

comparing kunnr.

if not i_vbak_temp[] is initial.

select kunnr

name1

from kna1

into table it_kna1

for all entries in i_vbak_temp

where kunnr eq i_vbak_temp-kunnr.

endif.

select vbeln

land1

from vbpa

into table it_vbpa

for all entries in i_vbak

where vbeln eq i_vbak-vbeln.

if sy-subrc eq 0.

select land1

zregion2

from zbwcntry

into table it_zbwcntry

for all entries in it_vbpa

where land1 = it_vbap-land1.

endif.

endif.

LOOP AT i_vbak.

CLEAR: itab.

itab-kunnr = i_vbak-kunnr .

itab-vbeln = i_vbak-vbeln .

itab-vkorg = i_vbak-vkorg .

itab-spart = i_vbak-spart .

itab-vtweg = i_vbak-vtweg .

itab-ernam = i_vbak-ernam .

itab-knumv = i_vbak-knumv.

CLEAR wa_kna1.

READ TABLE it_kna1 INTO wa_kna1

WITH KEY kunnr = i_vbak-kunnr.

IF sy-subrc EQ 0.

itab-nam1 = wa_kna1-name1.

ENDIF.

CLEAR wa_vbpa.

READ TABLE it_vbpa INTO wa_vbpa

WITH KEY vbeln = i_vbak-vbpa.

IF sy-subrc EQ 0.

READ TABLE it_zbwcntry INTO wa_zbwcntry

WITH KEY land1 = wa_vbpa-land1.

IF sy-subrc EQ 0.

itab-zregion2 = wa_zbwcntry-zregion2.

ENDIF.

ENDIF.

LOOP AT i_vbap WHERE vbeln = i_vbak-vbeln .

itab-posnr = i_vbap-posnr .

itab-matnr = i_vbap-matnr .

CLEAR wa_makt.

READ TABLE it_makt INTO wa_makt

WITH KEY matnr = i_vbap-matnr.

IF sy-subrc EQ 0.

itab-maktx = wa_maktx-maktx.

ENDIF.

READ TABLE itemp WITH KEY vbeln1 = i_vbap-vbeln.

IF sy-subrc EQ 0.

LOOP AT i_cdhdr WHERE objectid = itemp-vbeln .

itab-username = i_cdhdr-username .

itab-udate = i_cdhdr-udate .

itab-utime = i_cdhdr-utime .

LOOP AT i_cdpos WHERE objectclas = i_cdhdr-objectclas

AND objectid = i_cdhdr-objectid

AND changenr = i_cdhdr-changenr.

IF i_cdpos-tabkey+0(6) = i_vbap-posnr AND (

i_cdpos-tabkey+11(4) EQ 'PR00' OR

i_cdpos-tabkey+11(4) EQ 'ZPRK' OR

i_cdpos-tabkey+11(4) EQ 'ZPRD' OR

i_cdpos-tabkey+11(4) EQ 'ZPRF' OR

i_cdpos-tabkey+11(4) EQ 'ZPRB' OR

i_cdpos-tabkey+11(4) EQ 'ZTAR' ).

CASE i_cdpos-fname.

WHEN 'WAERS'.

itab-curky_new = i_cdpos-value_new .

itab-curky_old = i_cdpos-value_old .

itab-kschl = i_cdpos-tabkey+11(4).

WHEN 'KBETR'.

itab-amt_new = i_cdpos-value_new .

itab-amt_old = i_cdpos-value_old .

itab-kschl = i_cdpos-tabkey+11(4).

WHEN 'KMEIN',

itab-uom_new = i_cdpos-value_new .

itab-uom_old = i_cdpos-value_old .

itab-kschl = i_cdpos-tabkey+11(4).

itab-uomc = 'Y'.

WHEN 'KPEIN',

itab-per_new = i_cdpos-value_new .

itab-per_old = i_cdpos-value_old .

itab-kschl = i_cdpos-tabkey+11(4).

ENDCASE.

ELSE.

ENDIF.

IF itab-kschl IN s_kschl .

IF itab-amt_old NE ' '

AND itab-amt_new NE ' '.

SHIFT itab-vbeln LEFT DELETING LEADING '0'.

APPEND itab.

CLEAR itab.

ENDIF.

ELSE.

CONTINUE.

ENDIF.

ENDLOOP.

ENDIF.

ENDLOOP .

ENDLOOP.

LOOP AT i_vbak .

READ TABLE itab WITH KEY vbeln = i_vbak-vbeln .

IF sy-subrc NE 0 .

CLEAR itab .

itab-knumv = i_vbak-knumv .

itab-kunnr = i_vbak-kunnr .

itab-vbeln = i_vbak-vbeln .

itab-vkorg = i_vbak-vkorg .

itab-spart = i_vbak-spart .

itab-vtweg = i_vbak-vtweg .

itab-ernam = i_vbak-ernam .

itab-username = i_vbak-ernam.

SELECT SINGLE name1 INTO itab-name1 FROM kna1

WHERE kunnr = itab-kunnr .

SELECT SINGLE * FROM vbpa INTO t_vbpa

WHERE vbeln = itab-vbeln .

SELECT SINGLE zregion2 INTO itab-zregion2 FROM zbwcntry

WHERE land1 = t_vbpa-land1.

LOOP AT i_vbap WHERE vbeln = i_vbak-vbeln .

itab-posnr = i_vbap-posnr .

itab-matnr = i_vbap-matnr .

SELECT SINGLE maktx INTO itab-maktx

FROM makt

WHERE matnr = i_vbap-matnr .

LOOP AT i_zprice WHERE vbeln = i_vbak-vbeln

AND posnr = i_vbap-posnr .

IF i_zprice-kschl = 'PR00'.

itab-amt_new = i_zprice-amount .

itab-kschl = 'PR00'.

itab-amt_old = i_zprice-amount_old.

itab-curky_old = i_zprice-waers .

itab-curky_new = i_zprice-waers_new .

itab-utime = i_zprice-crtime .

itab-udate = i_zprice-crdate .

ENDIF .

IF i_zprice-kschl = 'ZPRK'.

itab-amt_new = i_zprice-amount .

itab-kschl = 'ZPRK'.

itab-amt_old = i_zprice-amount_old.

itab-curky_old = i_zprice-waers .

itab-curky_new = i_zprice-waers_new .

itab-utime = i_zprice-crtime .

itab-udate = i_zprice-crdate .

ENDIF .

IF i_zprice-kschl = 'ZPRF'.

itab-amt_new = i_zprice-amount .

itab-kschl = 'ZPRF'.

itab-amt_old = i_zprice-amount_old.

itab-curky_old = i_zprice-waers .

itab-curky_new = i_zprice-waers_new .

itab-utime = i_zprice-crtime .

itab-udate = i_zprice-crdate .

ENDIF .

IF i_zprice-kschl = 'ZPRD'.

itab-amt_new = i_zprice-amount .

itab-kschl = 'ZPRD'.

itab-amt_old = i_zprice-amount_old.

itab-curky_old = i_zprice-waers .

itab-curky_new = i_zprice-waers_new .

itab-utime = i_zprice-crtime .

itab-udate = i_zprice-crdate .

ENDIF .

IF itab-kschl IN s_kschl .

IF itab-amt_old NE ' '

AND itab-amt_new NE ' '.

SHIFT itab-vbeln LEFT DELETING LEADING '0'.

APPEND itab .

ENDIF.

ELSE .

CONTINUE.

ENDIF.

ENDLOOP .

ENDLOOP .

ENDIF .

ENDLOOP .

IF NOT itab[] IS INITIAL .

SELECT * FROM konv INTO CORRESPONDING FIELDS OF TABLE

i_konv FOR ALL ENTRIES IN itab

WHERE knumv = itab-knumv

AND kposn = itab-posnr

AND kschl = itab-kschl .

if sy-subrc eq 0.

SELECT knumh

kvewe

kotabnr

FROM konh

INTO TABLE i_konh

for all entries in i_konv

WHERE knumh eq i_knov-knumv.

ENDIF .

LOOP AT itab .

t_tabix = sy-tabix .

READ TABLE i_konv WITH KEY knumv = itab-knumv

kposn = itab-posnr

kschl = itab-kschl .

IF sy-subrc = 0 .

IF i_konv-kherk = 'A' OR

i_konv-kherk = 'C' .

itab-uom_old = i_konv-kmein .

itab-kherk = i_konv-kherk.

ELSE .

itab-uom_old = i_konv-kmein.

itab-kherk = 'X'. .

ENDIF .

IF itab-amt_new IS NOT INITIAL AND itab-amt_old IS NOT INITIAL.

IF itab-amt_new GT itab-amt_old .

itab-chg = 'H'.

ELSE.

itab-chg = 'L'.

ENDIF.

ELSE.

itab-chg = ' '.

ENDIF.

IF itab-amt_new NE itab-amt_old.

itab-rpri = 'Y'.

ENDIF.

IF itab-curky_old NE itab-curky_new.

itab-ccid = 'Y'.

ENDIF.

IF itab-uom_old NE itab-uom_new.

itab-uomc = 'Y'.

ENDIF.

IF itab-per_old NE itab-per_new.

itab-puc = 'Y'.

ENDIF.

clear :wa_konh.

read table it_konh into wa_konh

with key knumh = itab-knumv.

if sy-subrc eq 0.

CONCATENATE l_kvewe l_kotabnr INTO l_new.

SELECT SINGLE

ddtext

FROM dd02t

INTO itab-l_ddtext

WHERE tabname = l_new.

endif.

MODIFY itab INDEX t_tabix .

ENDIF .

ENDLOOP .

ENDFORM. " collect_data

Cheers

Joginder

Read only

Former Member
0 Likes
2,433

Please suggest ....am i doing correctly..

my final internal table being itab and description will come from DDTEXT that will be populated into l_text through fieldcatalog.

kindly reply.

data:l_kvewe type konh-kvewe,

l_kotabnr type konh-kotabnr,

l_new type c,

l_ddtext type DD02T-ddtext.

loop at itab.

IF not i_konh is initial.

select knumh

kvewe

kotabnr

from konh

into corresponding fields of table i_konh

where kvewe = l_kvewe

and kotabnr = l_kotabnr.

concatenate l_kvewe l_kotabnr into l_new.

if sy-subrc = 0.

select single TABNAME

DDTEXT

from dd02t

into itab

where ddtext = itab-l_ddtext.

l_ddtext = l_new.

endif.

endif.

append itab.

endloop.

Read only

0 Likes
2,433

No Your code is incorrect . Can you post the whole code . Well that would help me to give a proper solution.

Some of the Issues in the code

1) With in a Loop you using a Select statment ( Not advise to do)

2) You have kept a if condtion on IF not i_konh is initial. if it is initernal table [] is missing as well after this statement you are getting the data into the same table which is incorrect.

3) Your are not using primary key for selection of data from konh

more issue in your code.

Better place your whole i will modify and sent if possible.

Cheers

Joginder