Skip to Content
0
Former Member
Feb 18, 2014 at 11:36 AM

Problem fetching multiple line.

22 Views

Hello Experts,


Can you please help me with the code. I don't know where i am doing wrong. I am not able to fetch multiple lines in ty_vend_org and ty_avl_sel only one line is getting fetched i guess it is something to do with the work area deceleration part.



*&---------------------------------------------------------------------*

*& Report Z_AVL_TEST2

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT z_avl_test2

NO STANDARD PAGE HEADING.

TABLES: but000,

bbpm_but_frg0061,

bbpd_pd_index,

crmd_orderadm_h,

but100.

*&---------------------------------------------------------------------*

*& TYPE DECLERATION

*&---------------------------------------------------------------------*

TYPES : BEGIN OF ty_vend_det,

partner TYPE bu_partner, "PARTNER NUMBER

partner_guid TYPE bu_partner_guid, "PARTNER GUID

END OF ty_vend_det.

TYPES: BEGIN OF ty_vend_org,

partner_guid TYPE bu_partner_guid, "PARTNER GUID

purchase_org TYPE bbp_proc_org, "PURCHASE ORGANIZATION

END OF ty_vend_org.

TYPES: BEGIN OF ty_avl_sel,

header TYPE crmt_object_guid, "AVL GUID

category TYPE bbp_category_guid, "PRODUCT CATEGORY GUID

category_id TYPE bbp_category_id, "PRODUCT CATEGORY ID

vendor_id TYPE bu_partner, "PARTNER NUMBER

END OF ty_avl_sel.

TYPES: BEGIN OF ty_avl_no,

guid TYPE crmt_object_guid, "AVL GUID

object_id TYPE crmt_object_id_db, "AVL NUMBER

END OF ty_avl_no.

TYPES : BEGIN OF ty_final, "FINAL IT FOR DATA EXTRACTION

partner TYPE bu_partner,

partner_guid TYPE bu_partner_guid,

purchase_org TYPE bbp_proc_org,

header TYPE crmt_object_guid,

category TYPE bbp_category_guid,

category_id TYPE bbp_category_id,

* vendor_id TYPE bu_partner,

guid TYPE crmt_object_guid,

object_id TYPE crmt_object_id_db,

END OF ty_final.

TYPES: BEGIN OF ty_vend_validation, "TABLE TO VALIDATE WHETHER BP IS VENDOR OR NOT

partner TYPE bu_partner, "PARTNER NUMBER

rltyp TYPE bu_partnerrole, "BP ROLE

END OF ty_vend_validation.

*&---------------------------------------------------------------------*

*& DATA DECLERATION

*&---------------------------------------------------------------------*

DATA: it_vend_det TYPE STANDARD TABLE OF ty_vend_det WITH HEADER LINE,

it_vend_org TYPE STANDARD TABLE OF ty_vend_org WITH HEADER LINE,

it_avl_sel TYPE STANDARD TABLE OF ty_avl_sel WITH HEADER LINE,

it_avl_no TYPE STANDARD TABLE OF ty_avl_no WITH HEADER LINE,

it_final TYPE STANDARD TABLE OF ty_final WITH HEADER LINE,

it_vend_validation TYPE STANDARD TABLE OF ty_vend_validation WITH HEADER LINE.

DATA: wa_vend_det TYPE ty_vend_det,

wa_vend_org TYPE ty_vend_org,

wa_avl_sel TYPE ty_avl_sel,

wa_avl_no TYPE ty_avl_no,

wa_final TYPE ty_final,

wa_vend_validation TYPE ty_vend_validation.

INITIALIZATION.

*&---------------------------------------------------------------------*

*& SELECTION SCREEN

*&---------------------------------------------------------------------*

SELECT-OPTIONS: s_vend FOR it_vend_det-partner NO-EXTENSION

NO INTERVALS

OBLIGATORY.

* s_prod FOR it_avl_sel-category_id NO-EXTENSION

* NO INTERVALS.

START-OF-SELECTION.

*BREAK-POINT.

*&---------------------------------------------------------------------*

*& DATA EXTRACTION

*&---------------------------------------------------------------------*

SELECT partner

rltyp

FROM but100

INTO TABLE it_vend_validation

WHERE rltyp = 'BBP000'.

SELECT partner

partner_guid

FROM but000

INTO TABLE it_vend_det

FOR ALL ENTRIES IN it_vend_validation

WHERE partner = it_vend_validation-partner AND

partner IN s_vend.

SELECT partner_guid

purchase_org

FROM bbpm_but_frg0061

INTO TABLE it_vend_org

FOR ALL ENTRIES IN it_vend_det

WHERE partner_guid = it_vend_det-partner_guid.

SELECT header

category

category_id

vendor_id

FROM bbpd_pd_index

INTO TABLE it_avl_sel

FOR ALL ENTRIES IN it_vend_det

WHERE vendor_id = it_vend_det-partner.

* and

* category_id in s_prod.

SELECT guid

object_id

FROM crmd_orderadm_h

INTO TABLE it_avl_no

FOR ALL ENTRIES IN it_avl_sel

WHERE guid = it_avl_sel-header.

*&---------------------------------------------------------------------*

*& DISPLAYING DATA

*&---------------------------------------------------------------------*

LOOP AT it_vend_det INTO wa_vend_det.

wa_final-partner = wa_vend_det-partner.

wa_final-partner_guid = wa_vend_det-partner_guid.

READ TABLE it_vend_org INTO wa_vend_org WITH KEY partner_guid = wa_vend_det-partner_guid.

IF sy-subrc EQ 0.

wa_final-purchase_org = wa_vend_org-purchase_org.

ENDIF.

READ TABLE it_avl_sel INTO wa_avl_sel WITH KEY vendor_id = wa_vend_det-partner.

IF sy-subrc EQ 0.

wa_final-header = wa_avl_sel-header.

wa_final-category = wa_avl_sel-category.

wa_final-category_id = wa_avl_sel-category_id.

* wa_final-vendor_id = wa_avl_sel-vendor_id.

ENDIF.

READ TABLE it_avl_no INTO wa_avl_no WITH KEY guid = wa_avl_sel-header.

IF sy-subrc EQ 0.

wa_final-guid = wa_avl_no-guid.

wa_final-object_id = wa_avl_no-object_id.

ENDIF.

APPEND wa_final TO it_final.

CLEAR : wa_final.

BREAK-POINT.

ENDLOOP.






Regards,


Sarnava