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: 

ABAP : data fatching problem

former_member226520
Participant
0 Kudos
104

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

6 REPLIES 6

Former Member
0 Kudos
71

Do you want to keep records for a Customer for the current date only?

Is that what you are looking for?

Thanks,

Shambu

former_member209920
Active Participant
0 Kudos
71

Hi

you have explained a lot.

But the question is "where is the problem ' ??

0 Kudos
71

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

0 Kudos
71

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.

0 Kudos
71

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

0 Kudos
71

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