Application Development 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: 

Query in replace values to another field in download report

kabil_g
Active Participant
0 Kudos

Dear Friends,

I have a download report if plant 1000 & 1001 has same material , Description ,

It has to download the 2nd plant moving average price, 1st plant line has to delete from the file.Pls help me out.

Plant Material NumberDescriptionMoving average price
10001105001RYO 12
10011105001RYO4000

Kabil

9 REPLIES 9

gouravkumar64
Active Contributor
0 Kudos

Hi,

I guess your requirement like this.

Suppose in your internal table 3 plant is there.

1001,1002,1003 with same material.

You want last means 1003,then you can

SORT IT_TAB descending by plant.

read table index 1.

Will it works? Try it.

Thanks

Gourav

former_member225688
Participant
0 Kudos

Hi Kabil,

Its very simple use below logic.

Sort internal table.

Read internal table with the material number and check the next line has same material number and if so delete current line .

Loop At Itab.

Read itab with index  ( sy-tabix + 1 ).

Check if current material num =  next material num

IF sucess.

Delete current line.

END if.

ENDLOOP

at the end you will have only the data you need . Please let me know if this is useful.

kabil_g
Active Participant
0 Kudos

AS you suggested , similar, i have different scenario also

My concern is i want to check and compare  the material in a different plant if available i want to remove particular plant.

Kabil

0 Kudos

SORT itab BY material mov_avg_price DESCENDING.

DELETE ADJASCENT DUPLICATES FROM itab COMPARING material.

0 Kudos

Hi Sharath,

  If the same plant have same  kind of materials as shown below, in that case also it will be deleted.

PlantMaterial NumberDescriptionMoving average price
10001105001RYO12
10001105001RYO4000

Regards

Rajkumar Narasimman

0 Kudos

We all are getting confuse . Let me have a clear idea on your requirement .

Can you please tell me your clear requirement with example?

kabil_g
Active Participant
0 Kudos

Hi Dnyaneshwar,

My scenario is 4 plants has same materiall

Need to compare if 2001 & 2134 material code is available

it has to read the 2134 plant code material only , need to remove 2001 plant line

like wise same to 4000 & 4071 compare most the case 4 plants have same material

\

PlantMaterialMAP
200111050010410200
213411050010410300
400011050010410400
407111050010410500

0 Kudos

SORT itab BY plant DESCENDING material.

     LOOP AT itab INTO itab_line.

       lv_sytabix = sy-tabix + 1.

       READ TABLE itab INTO itab_line_tmp INDEX lv_sytabix.

        IF sy-subrc           = 0 AND

          itab_line-material(1) = itab_line_tmp-material(1).

         lv_sytabix = lv_sytabix - 1.

         DELETE itab INDEX lv_sytabix.

       ENDIF.

     ENDLOOP.

rajkumarnarasimman
Active Contributor
0 Kudos

Hi Kabil,


kabil G wrote:

Plant Material Number Description Moving average price
1000 1105001 RYO 12
1001 1105001 RYO 4000

Use deletion indicator concept, add additional field in the structure del_ind.


types: begin of ty_final.

          plant type plant,

          --

          ---

          del_ind type i,          "Delettion indicator field.

          end of ty_final.

sort it_final by plant matnr.

loop at it_final assiging <fs_final>

     "Get the index value

     l_index = sy-tabix.

     "Add index value for comparing next value

     l_index = l_index + 1.     

    

     "Check internal table

    read it_final into wa_final

        from l_index

        with key plant = <fs_final>-plant and matnr = <fs_final>-matnr.

     if sy-subrc = 0.    

     "Set the Deletion indicator

      <fs_final>-del_ind = 1.

     endif.    

    

endloop.

delete it_final where del_ind = 1.

Regards

Rajkumar Narasimman