‎2013 Jul 01 1:28 PM
Hi,
I am unable to retrieve exnum1.
SELECT SINGLE docyr exnum INTO (itab-docyr,itab-exnum) FROM j_1iexchdr WHERE rdoc = itab-vbeln.
IF itab-docyr IS NOT INITIAL AND itab-exnum IS NOT INITIAL.
SELECT SINGLE exnum INTO itab-exnum1 FROM j_1iexcdtl WHERE trntyp = 'ARE1' AND docyr = itab-docyr AND werks = itab-werks AND
rdoc2 = itab-exnum.
ENDIF.
MODIFY itab TRANSPORTING docyr exnum exnum1.
Regards
Kalpana
‎2013 Jul 01 1:41 PM
Hi,
Why you are selecting the same from header and then item table EXNUM you are already getting from
j_1iexchdr along with RDOC you can also pass trntyp = 'ARE1' in first select query.
regards,
zafar
‎2013 Jul 02 6:28 AM
Hi zafar,
CLEAR exnum.
SELECT SINGLE exnum INTO exnum FROM j_1iexchdr WHERE rdoc = itab-vbeln.
itab-exnum = exnum.
MODIFY itab TRANSPORTING exnum.
Already exnum was picking from j_1iexchdr.
Now I have a modification to pick ARE1 No. with condition:
vbrk-vbeln = j_1iexchdr-rdoc
I have to get rdoc2 where j_1iexchdr-exnum = j_1iexcdtl-exnum
And then I have to pick exnum where j_1iexchdtl-trntyp = 'ARE1' and year-docyr and j_1iexchdtl-werks
Regards
Kalpana
‎2013 Jul 01 1:43 PM
Hi Kalpana,
Try the below code. please keep the itab into loop and then try to modify the data otherwise how can it select the data from second quire.
SELECT SINGLE docyr
exnum
INTO (itab-docyr,itab-exnum)
FROM j_1iexchdr
WHERE rdoc = itab-vbeln.
LOOP AT itab.
IF itab-docyr IS NOT INITIAL AND itab-exnum IS NOT INITIAL.
SELECT SINGLE exnum
INTO itab-exnum1
FROM j_1iexcdtl
WHERE trntyp = 'ARE1'
AND docyr = itab-docyr
AND werks = itab-werks
AND rdoc2 = itab-exnum.
IF sy-subrc = 0.
MODIFY itab TRANSPORTING docyr exnum exnum1.
ENDIF.
ENDIF.
ENDLOOP.
Let me know if any issues.
Regards,
Gurunath
‎2013 Jul 02 5:11 AM
Hi,
It was not working. If I do this, it was modifying previous values too..
Regards
Kalpana
‎2013 Jul 02 7:08 AM
Hi,
Try below logic, create 2 internal tables i_exchdr and i_excdtl with the fields in below SELECTs
and then loop the itab table to fill the fields.
FIELD-SYMBOLS : <fs_itab> LIKE LINE OF itab.
SELECT docyr
exnum
rdoc
FROM j_1iexchdr
INTO TABLE i_exchdr
FOR ALL ENTRIES IN itab
WHERE rdoc = itab-vbeln.
IF sy-subrc = 0.
SORT i_exchdr.
SELECT docyr
werks
exnum
rdoc2
FROM j_1iexcdtl
INTO TABLE i_excdtl
FOR ALL ENTRIES IN i_exchdr
WHERE trntyp = 'ARE1'
AND docyr = i_exchdr-docyr
AND rdoc2 = i_exchdr-exnum.
IF sy-subrc = 0.
SORT i_exchdtl.
ENDIF.
ENDIF.
LOOP AT itab ASSIGNING <fs_itab>.
READ TABLE i_exchdr INTO wa_exchdr WITH KEY
rdoc = <fs_itab>-vbeln.
IF sy-subrc = 0.
* Update j_1iexchdr fields
<fs_itab>-docyr = wa_exchdr-docyr.
<fs_itab>-exnum = wa_exchdr-exnum.
READ TABLE i_excdtl INTO wa_excdtl WITH KEY
docyr = wa_exchdr-docyr
werks = <fs_itab>-werks
rdoc2 = wa_exchdr-exnum.
IF sy-subrc = 0.
* Update j_1iexcdtl fields
<fs_itab>-exnum1 = wa_excdtl-exnum.
ENDIF.
ENDIF.
CLEAR : wa_exchdr, wa_excdtl.
ENDLOOP.
Thanks & Regards
Bala Krishna
‎2013 Jul 05 7:21 AM
Hi,
What exactly my requirement is:
vbrk-vbeln = j_1iexchdr-rdoc
I have to get rdoc2 where j_1iexchdr-exnum = j_1iexcdtl-exnum
And then I have to pick exnum where j_1iexchdtl-trntyp = 'ARE1' and year-docyr and j_1iexchdtl-werks.
Now I have to pick Exnum1(Are1 No.) without effecting other values by using bove condition..
Already exnum was picking from j_1iexchdr.
LOOP AT itab1.
CLEAR exnum.
SELECT SINGLE exnum INTO exnum FROM j_1iexchdr WHERE rdoc = itab-vbeln.
itab-exnum = exnum.
MODIFY itab TRANSPORTING exnum.
ENDLOOP.
I have given my code at very first. Can anyone help me in this.
Regards
Kalpana
‎2013 Jul 05 7:53 AM
Hi,
Try below coding, transporting is not required since we are not changing the other fields of itab same values will be modified but if you want you can add it.
loop at itab.
select single DOCYR DOCNO INTO (itab-docyr,itab-exnum) from J_1IEXCHDR WHERE rdoc = itab-vbeln.
IF itab-docyr IS NOT INITIAL AND itab-exnum IS NOT INITIAL.
SELECT SINGLE exnum INTO itab-exnum1 FROM j_1iexcdtl WHERE trntyp = 'ARE1' AND docyr = itab-docyr AND werks = itab-werks AND
rdoc2 = itab-exnum.
modify itab.
endif.
endloop.
Regards
Chudamani
‎2013 Jul 05 10:38 AM
‎2013 Jul 05 10:45 AM
Hi,
What is the problem? is data getting selected from table J_1IEXCHDR and j_1iexcdtl or problem is while modifying?
Regards
‎2013 Jul 06 8:48 AM
Hi,
Unable to get the data from both of the tables.
Just check once my code.
SELECT SINGLE docyr exnum INTO (itab-docyr, itab-exnum) FROM j_1iexchdr WHERE rdoc = itab-vbeln.
IF itab-docyr IS NOT INITIAL AND itab-exnum IS NOT INITIAL.
SELECT SINGLE exnum INTO itab-exnum1 FROM j_1iexcdtl WHERE trntyp = 'ARE1' AND docyr = itab-docyr AND werks = itab-werks AND rdoc2 = itab-exnum.
ENDIF.
MODIFY itab TRANSPORTING docyr exnum exnum1.
From the above query, the data was retrieving correctly.
But it was effecting other values. Without effecting other values, how can I get Exnum1. That is what Im asking. I think u understood now what my prob is!
Regards
Kalpana
‎2013 Jul 06 2:52 PM
Hi Kalpana,
As per my understanding, you want to get exnum from j_1iexcdtl and modify your itab. keep your selection as you have written you are correct. just take field-Symbols as shown below.
********
******Declare field-symbols.
FIELD-SYMBOLS : <lfs_itab> like LINE OF itab.
SELECT SINGLE docyr exnum
INTO (itab-docyr,itab-exnum)
FROM j_1iexchdr
WHERE rdoc = itab-vbeln.
LOOP AT itab ASSIGNING <lfs_itab>.
IF <lfs_itab>-docyr IS NOT INITIAL AND <lfs_itab>-exnum IS NOT INITIAL.
SELECT SINGLE exnum
INTO <lfs_itab>-exnum1
FROM j_1iexcdtl
WHERE trntyp = 'ARE1'
AND docyr = itab-docyr
AND werks = itab-werks
AND rdoc2 = itab-exnum.
ENDIF.
ENDLOOP.
Regards
‎2013 Jul 07 11:54 AM
Hi Kalpana,
As Amit suggested,you must use field symbols in this case or you can use conditions in modify statement.
The select query you are using is fine and if you dont want to use field-symbols then you can either use conditions while moditying itab OR you can take another internal table similar to itab and store the changed value in it.Later on you can insert them into orignal table itab by deleting previous records.
But this method is quite tedious.
Thus i suggest you to use either field symbols or use condition in modify statement.
Regards,
Abdul