Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problem ABAP

Hi.

I have a problem in an abap. In this program abap, this repeating some records I do not deal for that it does it.

FORM search_material_data TABLES p_t_data STRUCTURE zmm_mat_master_ext.

DATA : L_FLAG(1) TYPE C VALUE 'N'.

DATA: BEGIN OF it_vdarl OCCURS 0,

ranl LIKE vdarl-ranl,

derf LIKE vdarl-derf,

sgrp4 LIKE vdarl-sgrp4,

rdarnehm LIKE vdarl-rdarnehm,

ranlalt1 LIKE vdarl-ranlalt1,

gsber LIKE vdarl-gsber,

bukrs LIKE vdarl-bukrs,

santwhr LIKE vdarl-santwhr,

END OF it_vdarl.

DATA: BEGIN OF it_0011 OCCURS 0,

opera LIKE zmm_t0011-opera,

charg LIKE zmm_t0011-charg,

posnr LIKE zmm_t0011-posnr,

tipoa LIKE zmm_t0011-tipoa,

hechu LIKE zmm_t0011-hechu,

mater LIKE zmm_t0011-mater,

estad LIKE zmm_t0011-estad,

pesot LIKE zmm_t0011-pesot,

avalu LIKE zmm_t0011-avalu,

avamo LIKE zmm_t0011-avamo,

prede LIKE zmm_t0011-prede,

bresg LIKE zmm_t0011-bresg,

total LIKE zmm_t0011-total,

press LIKE zmm_t0011-press,

facmo LIKE zmm_t0011-facmo,

totre LIKE zmm_t0011-totre,

END OF it_0011.

DATA: BEGIN OF it_0012 OCCURS 0,

opera LIKE zmm_t0012-opera,

posme LIKE zmm_t0012-posme,

posnr LIKE zmm_t0012-posnr,

tipge LIKE zmm_t0012-tipge,

pesot LIKE zmm_t0012-pesot,

*MODIF01

taman LIKE zmm_t0012-taman,

avalu LIKE zmm_t0012-avalu,

avamo LIKE zmm_t0012-avamo,

prede LIKE zmm_t0012-prede,

press LIKE zmm_t0012-press,

bresg LIKE zmm_t0012-bresg,

*MODIF01

END OF it_0012.

DATA: it_0012s LIKE SORTED TABLE OF it_0012 WITH NON-UNIQUE KEY opera posme

WITH HEADER LINE.

DATA: BEGIN OF it_0036 OCCURS 0,

opera LIKE zmm_t0036-opera,

charg LIKE zmm_t0036-charg,

posnr LIKE zmm_t0036-posnr,

tipre LIKE zmm_t0036-tipre,

mater LIKE zmm_t0036-mater,

estre LIKE zmm_t0036-estre,

pesot LIKE zmm_t0036-pesot,

avalu LIKE zmm_t0036-avalu,

avamo LIKE zmm_t0036-avamo,

prede LIKE zmm_t0036-prede,

bresg LIKE zmm_t0036-bresg,

total LIKE zmm_t0036-total,

descr LIKE zmm_t0036-descr,

marca LIKE zmm_t0036-marca,

tipmo LIKE zmm_t0036-tipmo,

compl LIKE zmm_t0036-compl,

press LIKE zmm_t0036-press,

valpro LIKE zmm_t0036-valpro,

facmo LIKE zmm_t0036-facmo,

totre LIKE zmm_t0036-totre,

END OF it_0036.

DATA: BEGIN OF it_0046 OCCURS 0,

opera LIKE zmm_t0046-opera,

charg LIKE zmm_t0046-charg,

posnr LIKE zmm_t0046-posnr,

mater LIKE zmm_t0046-mater,

estre LIKE zmm_t0046-estre,

avalu LIKE zmm_t0046-avalu,

avamo LIKE zmm_t0046-avamo,

prede LIKE zmm_t0046-prede,

bresg LIKE zmm_t0046-bresg,

total LIKE zmm_t0046-total,

descr LIKE zmm_t0046-descr,

marca LIKE zmm_t0046-marca,

press LIKE zmm_t0046-press,

valpro LIKE zmm_t0046-valpro,

facmo LIKE zmm_t0046-facmo,

totre LIKE zmm_t0046-totre,

cofam LIKE zmm_t0046-cofam,

artic LIKE zmm_t0046-artic,

END OF it_0046.

LOOP AT p_t_data.

MOVE p_t_data-matnr+5(13) TO p_t_data-opera.

MOVE p_t_data-opera TO p_t_data-ranl.

MODIFY p_t_data TRANSPORTING opera ranl.

ENDLOOP.

SELECT ranl derf sgrp4 rdarnehm ranlalt1 gsber bukrs santwhr

FROM vdarl INTO TABLE it_vdarl

FOR ALL ENTRIES IN p_t_data

WHERE bukrs EQ '01'

AND sarchiv EQ space

AND ranl EQ p_t_data-ranl.

SORT it_vdarl BY ranl.

SELECT opera charg posnr tipoa hechu mater estad pesot avalu avamo

prede bresg total press facmo totre

FROM zmm_t0011 INTO TABLE it_0011

FOR ALL ENTRIES IN p_t_data

WHERE opera EQ p_t_data-opera

AND charg EQ p_t_data-charg.

IF sy-subrc EQ 0.

SORT it_0011 BY opera charg posnr.

*MODIF01

*SELECT opera posme posnr tipge pesot

SELECT opera posme posnr tipge pesot taman avalu avamo prede press bresg

*MODIF01

FROM zmm_t0012 INTO TABLE it_0012

FOR ALL ENTRIES IN it_0011

WHERE opera EQ it_0011-opera

AND posme EQ it_0011-posnr.

IF sy-subrc EQ 0.

SORT it_0012 BY opera posme posnr.

it_0012s] = it_0012[.

ENDIF.

ENDIF.

SELECT opera charg posnr tipre mater estre pesot avalu avamo prede

bresg total descr marca tipmo compl press valpro

facmo totre

FROM zmm_t0036 INTO TABLE it_0036

FOR ALL ENTRIES IN p_t_data

WHERE opera EQ p_t_data-opera

AND charg EQ p_t_data-charg.

SORT it_0036 BY opera charg.

SELECT opera charg posnr mater estre avalu avamo prede bresg total

descr marca press valpro facmo totre cofam artic

FROM zmm_t0046 INTO TABLE it_0046

FOR ALL ENTRIES IN p_t_data

WHERE opera EQ p_t_data-opera

AND charg EQ p_t_data-charg.

SORT it_0046 BY opera charg.

LOOP AT p_t_data WHERE posnrg = 0.

Datos del préstamo

READ TABLE it_vdarl WITH KEY ranl = p_t_data-opera

BINARY SEARCH.

IF sy-subrc EQ 0.

p_t_data-derf = it_vdarl-derf.

p_t_data-sgrp4 = it_vdarl-sgrp4.

p_t_data-rdarn = it_vdarl-rdarnehm.

p_t_data-ranla = it_vdarl-ranlalt1.

p_t_data-gsber = it_vdarl-gsber.

p_t_data-bukrs = it_vdarl-bukrs.

p_t_data-waers = it_vdarl-santwhr.

MODIFY p_t_data TRANSPORTING derf sgrp4 rdarn ranla gsber bukrs waers.

ENDIF.

CASE p_t_data-sgrp4.

*Alhajas

WHEN '01'.

READ TABLE it_0011 WITH KEY opera = p_t_data-opera

charg = p_t_data-charg

BINARY SEARCH.

IF sy-subrc EQ 0.

LOOP AT it_0011 WHERE posnr > 0.

p_t_data-posnr = it_0011-posnr.

p_t_data-tipoa = it_0011-tipoa.

PERFORM check_string USING p_t_data-tipoa 20.

p_t_data-hechu = it_0011-hechu.

PERFORM check_string USING p_t_data-hechu 20.

p_t_data-mater = it_0011-mater.

PERFORM check_string USING p_t_data-mater 20.

p_t_data-estad = it_0011-estad.

PERFORM check_string USING p_t_data-estad 20.

p_t_data-pesot = it_0011-pesot.

p_t_data-avalu = it_0011-avalu.

p_t_data-avamo = it_0011-avamo.

p_t_data-prede = it_0011-prede.

p_t_data-bresg = it_0011-bresg.

p_t_data-total = it_0011-total.

p_t_data-press = it_0011-press.

p_t_data-facmo = it_0011-facmo.

p_t_data-totre = it_0011-totre.

p_t_data-peson = p_t_data-pesot - p_t_data-pesop.

*Peso de las piedras

L_FLAG = 'N'.

LOOP AT it_0012s WHERE opera EQ it_0011-opera

AND posme EQ it_0011-posnr.

*IF it_0012s-tipge EQ 'DIAMANTE'.

IF it_0012s-tipge NE ' '.

p_t_data-pesop = p_t_data-pesop + ( it_0012s-pesot * '0.2' ).

*MODIF01

p_t_data-tamang = it_0012s-taman.

p_t_data-avalug = it_0012s-avalu.

p_t_data-avamog = it_0012s-avamo.

p_t_data-predeg = it_0012s-prede.

p_t_data-pressg = it_0012s-press.

p_t_data-bresgg = it_0012s-bresg.

p_t_data-tipge = it_0012s-tipge.

p_t_data-posnrg = it_0012s-posnr.

p_t_data-peson = p_t_data-pesot - p_t_data-pesop.

*p_t_data-pesop = p_t_data-pesop + it_0012s-pesot.

*MODIF01

ELSE.

CONTINUE.

ENDIF.

IF p_t_data-posnrg EQ 01.

MODIFY p_t_data TRANSPORTING posnr tipoa hechu mater estad pesot

pesop peson avalu avamo prede bresg total press facmo totre

tamang avalug avamog predeg pressg bresgg posnrg tipge.

SORT p_t_data BY opera posnr posnrg.

L_FLAG = 'T'.

ELSE.

APPEND p_t_data.

SORT p_t_data BY opera posnr posnrg.

L_FLAG = 'T'.

ENDIF.

ENDLOOP.

IF L_FLAG NE 'T'.

MODIFY p_t_data TRANSPORTING posnr tipoa hechu mater estad pesot

pesop peson avalu avamo prede bresg total press facmo totre.

SORT p_t_data BY opera.

ENDIF.

ENDLOOP.

ENDIF.

ENDCASE.

ENDLOOP.

ENDFORM.

Edited by: Miguel Angel Catalan on Oct 1, 2008 4:10 PM

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question