Application Development and Automation 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: 
Read only

How to read values from deep structure?

Former Member
0 Likes
6,164

Helo Gurus !!!

I am using function module LB_BIL_INV_OUTP_READ_PRTDATA to read invoice details.

This function module returns data in a deep structure.

I want ti read a value from a particular table from it.

How to do it?

LB_BIL_INV_OUTP_READ_PRTDATA -


> LBBIL_INVOICE(main structure)--->HD_ADR (This is a table) -


>LBBIL_HD_ADR (Line type)----->PARTN_ROLE (Field to read)

Points are assured !!!!

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
2,512

Hello Anay

That is quite simple:


" Assumption: the fm returns data 
DATA: ls_hd_adr   LIKE LINE OF es_bil_invoice-hd_adr.  " Or:
DATA: ls_hd_adr   TYPE LBBIL_HD_ADR.

LOOP AT es_bil_invoice-hd_adr INTO ls_hd_adr.
  IF ( ls_hd_adr-PARTN_ROLE = 'AG' ).
...
  ELSE.
...
  ENDIF.
ENDLOOP.

Regards

Uwe

Helo Gurus !!!

I am using function module LB_BIL_INV_OUTP_READ_PRTDATA to read invoice details.

This function module returns data in a deep structure.

I want ti read a value from a particular table from it.

How to do it?

LB_BIL_INV_OUTP_READ_PRTDATA -


> LBBIL_INVOICE(main structure)--->HD_ADR (This is a table) -


>LBBIL_HD_ADR (Line type)----->PARTN_ROLE (Field to read)

Points are assured !!!!

3 REPLIES 3
Read only

uwe_schieferstein
Active Contributor
0 Likes
2,513

Hello Anay

That is quite simple:


" Assumption: the fm returns data 
DATA: ls_hd_adr   LIKE LINE OF es_bil_invoice-hd_adr.  " Or:
DATA: ls_hd_adr   TYPE LBBIL_HD_ADR.

LOOP AT es_bil_invoice-hd_adr INTO ls_hd_adr.
  IF ( ls_hd_adr-PARTN_ROLE = 'AG' ).
...
  ELSE.
...
  ENDIF.
ENDLOOP.

Regards

Uwe

Read only

Former Member
0 Likes
2,512

Hi.

Thanks for your reply, I tried, but its not working!!!

Actually I want to get ADRNR of both sold to and ship to from that table.

So I want to read these values from that table !!!

Read only

Barada_Swain
Participant
0 Likes
2,512

Hi Anay,

Refer the following code. It should solve ur problem.

REPORT y_test.

  • Inputs

DATA : v_objkey TYPE nast-objky,

wa_print_data TYPE lbbil_print_data_to_read,

v_parvw TYPE nast-parvw,

v_parnr TYPE nast-parnr,

v_spras TYPE nast-spras.

  • Results

DATA : wa_invoice TYPE lbbil_invoice,

wa_hd_adr TYPE lbbil_hd_adr,

v_partner_role TYPE parvw.

CALL FUNCTION 'LB_BIL_INV_OUTP_READ_PRTDATA'

EXPORTING

if_bil_number = v_objkey

is_print_data_to_read = wa_print_data

if_parvw = v_parvw

if_parnr = v_parnr

if_language = v_spras

IMPORTING

es_bil_invoice = wa_invoice

EXCEPTIONS

records_not_found = 1

records_not_requested = 2

OTHERS = 3.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • If successful do this

READ TABLE wa_invoice-hd_adr INTO wa_hd_adr INDEX 1.

IF sy-subrc EQ 0.

v_partner_role = wa_hd_adr-partn_role.

ENDIF.

WRITE : v_partner_role.

Note : I assume you are getting only one Partner Role in the export parameter, so I used read. In case tehre are more than one role loop at the table and use the values as required.