‎2020 Feb 15 1:17 PM
Hi Friends,
I am new to ABAP coding and have written one code as below. But GL_Account column is not being updated not sure why.
Can someone please help
TYPES:
BEGIN OF ty_mapping,
cond_type TYPE c LENGTH 30,
gl_account TYPE c LENGTH 10,
country TYPE c LENGTH 10,
distr_chan TYPE c LENGTH 10,
END OF ty_mapping.
DATA: lt_avfmapping TYPE STANDARD TABLE OF ty_mapping,
ls_avfmapping TYPE ty_mapping.
SELECT cond_type
gl_account
country
distr_chan
FROM /bic/ac_afinval2
INTO TABLE lt_avfmapping
WHERE ( src_trdp = 'No' or src_trdp = 'NO' ) and country = 'CCE' .
IF sy-subrc = 0.
SORT lt_avfmapping BY cond_typeDISTR_CHAN ASCENDING.
DELETE ADJACENT DUPLICATES FROM lt_avfmapping
COMPARING cond_type.
ENDIF.
FIELD-SYMBOLS:
<fs_datapak> LIKE LINE OF RESULT_PACKAGE.
LOOP AT RESULT_PACKAGE ASSIGNING <fs_datapak>.
READ TABLE lt_avfmapping INTO ls_avfmapping WITH KEY
cond_type = <fs_datapak>-KNART
distr_chan = <fs_datapak>-DISTR_CHAN .
IF sy-subrc = 0.
<fs_datapak>-GL_ACCOUNT = ls_avfmapping-gl_account .
ENDIF.
ENDLOOP .
‎2020 Feb 15 1:46 PM
Hi,
while using code in questions, use code button in order to view properly
‎2020 Feb 15 4:54 PM
When you debug your logic, are your tables filled with the information you expect? What happens in the loop when you are trying to set the gl_account?
So far you have not given enough information to help you out, one could only guess.
‎2020 Feb 15 5:47 PM
From the information you've given, there could be multiple sources of the problem.
What i would suggest is either you try to debug the program as @Michael Piersche suggested and see the types yourself or you post the exact types here, so someone could help.
As a sidenote - you don't use some nice new features available in abap since version 7.4, like new open sql syntax or inline declarations. You could look up the version of your system:
In the SAP GUI > under Menu: "System" > click on "Status ..." > in the section "SAP System data" > under "Product version" > click the magnifying glass > in the Tab "Installed Product Versions" look in the "Release" column for the Product "SAP NETWEAVER".
If the Version is >= 7.4, i could show you how to further simplify your code.
‎2020 Feb 15 5:48 PM
Please enter a meaningful title (currently, it has the same meaning as none title). And use the CODE button to format the code (as S Abinath said).
‎2020 Feb 16 12:34 PM
Hi,
Thanks for your replies. I am really sorry if i wasted you time but the issue was with one of the columns used in where clause. I rectified the data in that column and the same code worked.