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 New Syntax

kiran_k8
Active Contributor
0 Kudos
652

Hello Folks,

gs_head-smtp_addr = mt_adr6 [ kunnr = gs_vbrk-kunag ]-smtp_addr.

How to read the above syntax so that I can understand what it is doing ?

Thanks,

K Kiran.

12 REPLIES 12

FredericGirod
Active Contributor
499

I want the line of the internal table MT_ADR6 where the field KUNNR equal the value of the field gs_vbrk-kunag and I want in output only the value of the field SMTP_ADDR

READ TABLE mt_adr6  INTO  @data(ls_line_adr6) WITH KEY kunnr = gs_vbrk-kunag.
if sy-subrc eq 0.
gs_head-smtp_addr = ls_line_adr6-smtp_addr.
endif.

0 Kudos
499

Hello Fredric,

The problem is when I debug I am not able to find any value for mt_adr6-kunnr.

It is not reecognising mt_adr6 in debugging.

Thanks,

K Kiran.

0 Kudos
499

mt_adr6 should be an internal table, so in debug you should see something.

As we don't see how it is declared and populated it is little bit hard to help you.

Could you post screenshot of the debugger with the mt_adr6 ?

0 Kudos
499

Hello Folks,

The problem is when I debug I am not able to find any value for mt_adr6-kunnr or mt_adr6-smpt_addr

It is not reecognising mt_adr6 internal table in debugging ie I am not finding any value when I type mt_adr6-kunnr or mt_adr6-smtp_addr but in internal table it is present.

Kindly refer to the attached screenshsot.

.

Thanks,

K Kiran.

0 Kudos
499

The debugger show you the table MT_ADR6, you see there is one line in this table.

If you double click, you will change the tab from Desktop to Tables and see the content of the table.

when you put MT_ADR6-KUNNR or -SMTP_ADDR you are trying to display the content of one line, but it will not work as SAP doesn't know witch line you would like to display. You could for this by specified the line you would like to show : MT_ADR6[1]-KUNNR

Second point, MT_ADDR6-KUNNR in old abap code works, because there was a link between internal table and a header line. But it is not the case anymore.

thkolz
Contributor
0 Kudos
499

Get field smtp_addr with key gs_vbrk-kunnr of table mt_adr6

499

Actually you need to catch exception CX_SY_ITAB_LINE_NOT_FOUND.
Otherwise it will dump when there is no line for that customer.

      TRY.
          gs_head-smtp_addr = mt_adr6[ kunnr = gs_vbrk-kunag ]-smtp_addr.
        CATCH cx_sy_itab_line_not_found INTO DATA(r_exc).
          MESSAGE r_exc->get_text( ) TYPE 'E'.
      ENDTRY.

Sandra_Rossi
Active Contributor
499

Why don't you debug it?

Sandra_Rossi
Active Contributor
0 Kudos
499

what is mt_adr6?

what components does mt_adr6 have?

I think you can deduce a few things yourself.

adityaaufar
Participant
0 Kudos
499

Hi.

1. There are 3 work areas => `gs_head`, `mt_adr6`, and `gs_vbrk`
2. Both `gs_head` work area and `mt_adr6` work area has a field called `smtp_addr`
3. `mt_adr6` work area also has a field called `kunnr`
4. `gs_vbrk` work area has a field called `kunag`

5. What the code is trying to do is assign the `smtp_addr` field value in`mt_adr6` work area to`smtp_addr` field in`gs_head` work area BUT ONLY WHEN THE `kunnr` field value from `mt_adr6` work area match with the `kunag` field value from the `gs_vbrk` work area

Hope it helps!

kiran_k8
Active Contributor
0 Kudos
499

Hello Folks,

The problem is when I debug I am not able to find any value for mt_adr6-kunnr.

It is not reecognising mt_adr6 in debugging.

Thanks,

K Kiran.

SugguSandeep
Contributor
0 Kudos
499

Hi kiran.k8

For More Information about ABAP Expressions 7.5 in clear explanation Check Out this link: ABAP Expressions (7.4+) – Discovering ABAPWhich might help you
Thank You,Suggu Sandeep.