2012 Jun 28 9:12 AM
Dear friend ,
I have a requirement , that I have to insert the data of internal
table into ztable and then I have to update the data ,
But I have the problem in it.
select * from ZCUST_OUTSTNAD into CORRESPONDING FIELDS OF TABLE it_ZCUST_OUTSTNAD where x eq sy-datum.
"insert at the first time when ztable is empty.
IF SY-SUBRC NE 0.
LOOP AT IT_FINAL_AGE.
ZCUST_OUTSTNAD-KUNNR = IT_FINAL_AGE-KUNNR.
ZCUST_OUTSTNAD-CURRBAL = IT_FINAL_AGE-CURRBAL.
ZCUST_OUTSTNAD-CRDR = IT_FINAL_AGE-CRDR.
ZCUST_OUTSTNAD-X = SY-DATUM.
INSERT ZCUST_OUTSTNAD .
ENDLOOP.
ELSEIF SY-SUBRC EQ 0.
LOOP AT IT_FINAL_AGE.
update ZCUST_OUTSTNAD SET
CURRBAL = IT_FINAL_AGE-CURRBAL
CRDR = IT_FINAL_AGE-CRDR
X = SY-DATUM
WHERE KUNNR = IT_FINAL_AGE-KUNNR.
ENDLOOP.
ENDIF.
"I have to stay the data of the current date only
loop at it_ZCUST_OUTSTNAD.
IF it_ZCUST_OUTSTNAD-X LT SY-DATUM.
DELETE ZCUST_OUTSTNAD .
ENDIF.
endloop.
here I have to insert and update the data in to ztable it_ZCUST_OUTSTNAD:
of the internal table IT_FINAL.
I think you have got me.
Regards,
Rihan
SAP-abaper
Moderator message : Not enough re-search before posting, discussion locked.
Message was edited by: Vinod Kumar
2012 Jun 28 9:33 AM
Do you want to keep records for a Customer for the current date only?
Is that what you are looking for?
Thanks,
Shambu
2012 Jun 28 9:35 AM
Hi
you have explained a lot.
But the question is "where is the problem ' ??
2012 Jun 28 9:56 AM
yes Mr Shambhu I have the requirement of current date because that
is outstanding report of customer.
@Manu Ji : - the problem is that the data is not either inserting in the
z table nor updating .
I think there is some problem but where , I am unable to find it out.
Rihan
2012 Jun 28 10:01 AM
Hi Rihan,
Just few questions for my clarification.
1. Is your field X has sy-datum as its datatype?
2. And, just write clear statement after your INSERT statement. This might not be the problem but for a safer side, clear it before you add the next record.
3. And, please specify the primary keys in your table.
Regards,
Sindhu Pulluru.
2012 Jun 28 10:06 AM
Dear Mr sindhu,
1.yes X has sy-datum as its datatype?
2. I have written clear statement after I use INSERT statement.
3. Primary key is kunnr in my z table.
this error is coming :
The ABAP program lines are wider than the internal table.
Regards,
Rihan
2012 Jun 28 10:16 AM
Rewrite your code like this.
SELECT * FROM zcust_outstnad
INTO CORRESPONDING FIELDS OF TABLE it_zcust_outstnad
FOR ALL ENTRIES IN it_final_age
WHERE kunnr = it_final_age-kunnr.
LOOP AT it_final_age.
READ TABLE it_zcust_outstnad INTO wa_zcust_outstnad WITH KEY kunnr = it_final_age-kunnr.
IF sy-subrc NE 0.
zcust_outstnad-kunnr = it_final_age-kunnr.
zcust_outstnad-currbal = it_final_age-currbal.
zcust_outstnad-crdr = it_final_age-crdr.
zcust_outstnad-x = sy-datum.
INSERT zcust_outstnad .
ELSE.
UPDATE zcust_outstnad SET
currbal = it_final_age-currbal
crdr = it_final_age-crdr
x = sy-datum
WHERE kunnr = it_final_age-kunnr.
ENDIF.
ENDLOOP.
Thanks,
Shambu