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

Selecting Generic Entries from Data Dictionary.

Former Member
0 Likes
499

Hello All,

I have below requirement, for which i need your guidence.In the below red marked query the field WERKS is selected from the Z table.

Now for field WERKS generic selection need to work with either trailing or leading '*'.

Example:    DE1*         or  *E14. Need solution for this. Kindly provide the idea to acheive it.

LOOP AT gt_ekpo INTO gs_wa_ekpo.
    READ TABLE gt_ekko INTO gs_wa_ekko
                       WITH KEY ebeln = gs_wa_ekpo-ebeln
                       BINARY SEARCH.
    IF sy-subrc EQ 0 .
      gs_wa_ekko_fin-ebeln = gs_wa_ekko-ebeln.
      gs_wa_ekko_fin-bsart = gs_wa_ekko-bsart.
      gs_wa_ekko_fin-banfn = gs_wa_ekpo-banfn.
      gs_wa_ekko_fin-werks = gs_wa_ekpo-werks.
      gs_wa_ekko_fin-ebelp = gs_wa_ekpo-ebelp.
      APPEND gs_wa_ekko_fin TO gt_ekko_fin.
    ENDIF.
    CLEAR : gs_wa_ekpo,
            gs_wa_ekko,
            gs_wa_ekko_fin.
  ENDLOOP.

**Select entries from table ZMM_EMAIL_AF_T for Documnet types and Plants fetched from EKKO and EKPO tables.
  IF NOT gt_ekko_fin[] IS INITIAL.
    SELECT bsart werks aktiv
           banf first_mail z1st_email
           z2nd_email z3rd_email
           FROM zmm_email_pa_t
           INTO TABLE gt_zmm_email_pa_t
           FOR ALL ENTRIES IN gt_ekko_fin
           WHERE aktiv = gc_check AND
                 bsart = gt_ekko_fin-bsart AND
                 werks = gt_ekko_fin-werks.
    IF sy-subrc EQ 0.
      SORT gt_zmm_email_pa_t BY bsart werks.
    ENDIF.

  ENDIF.

**For the Documents whose plants and documents types are maintained in the table ZMM_EMAIL_AF_T
**check if flag BANF (Only with PR) is checked and then proceed to check if PR number is available
**for the same .
  SORT : gt_ekko_fin BY bsart werks.
  CLEAR : gs_wa_ekko_fin.
  LOOP AT gt_ekko_fin INTO gs_wa_ekko_fin.
    READ TABLE gt_zmm_email_pa_t INTO gs_wa_zmm_email_pa_t
                                 WITH KEY bsart = gs_wa_ekko_fin-bsart
                                          werks = gs_wa_ekko_fin-werks
                                          BINARY SEARCH.
    IF sy-subrc EQ 0.
      IF gs_wa_zmm_email_pa_t-banf = gc_check.
        IF gs_wa_ekko_fin-banfn IS NOT INITIAL.
          APPEND gs_wa_ekko_fin TO gt_ekko_fin2.
          APPEND gs_wa_zmm_email_pa_t TO gt_zmm_email_pa_t2.
        ENDIF.
      ELSE.
        APPEND gs_wa_ekko_fin TO gt_ekko_fin2.
        APPEND gs_wa_zmm_email_pa_t TO gt_zmm_email_pa_t2.
      ENDIF.
    ENDIF.
  ENDLOOP.

Thanks & Regards,

Chirag

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
463

Hi Chirag,

Try this..

Create an internal table of type SELOPT.

data: it_range type table of SELOPT,

        wa_range type selopt.

clear wa_range.

wa_range-sign = 'I'.

wa_range-option = 'CP' .  " Contains Pattern

wa_range-low = DE1*.

append wa_range to it_range.

clear wa_range.

wa_range-sign = 'I'.

wa_range-option = 'CP' .  " Contains Pattern

wa_range-low = *E14.

append wa_range to it_range.

In Select query:

Select <fields> from <table> into table <object> where werks in it_range.

Try this and post your doubts.

Thanks,

Manikandan JN.

Hello All,

I have below requirement, for which i need your guidence.In the below red marked query the field WERKS is selected from the Z table.

Now for field WERKS generic selection need to work with either trailing or leading '*'.

Example:    DE1*         or  *E14. Need solution for this. Kindly provide the idea to acheive it.

LOOP AT gt_ekpo INTO gs_wa_ekpo.
    READ TABLE gt_ekko INTO gs_wa_ekko
                       WITH KEY ebeln = gs_wa_ekpo-ebeln
                       BINARY SEARCH.
    IF sy-subrc EQ 0 .
      gs_wa_ekko_fin-ebeln = gs_wa_ekko-ebeln.
      gs_wa_ekko_fin-bsart = gs_wa_ekko-bsart.
      gs_wa_ekko_fin-banfn = gs_wa_ekpo-banfn.
      gs_wa_ekko_fin-werks = gs_wa_ekpo-werks.
      gs_wa_ekko_fin-ebelp = gs_wa_ekpo-ebelp.
      APPEND gs_wa_ekko_fin TO gt_ekko_fin.
    ENDIF.
    CLEAR : gs_wa_ekpo,
            gs_wa_ekko,
            gs_wa_ekko_fin.
  ENDLOOP.

**Select entries from table ZMM_EMAIL_AF_T for Documnet types and Plants fetched from EKKO and EKPO tables.
  IF NOT gt_ekko_fin[] IS INITIAL.
    SELECT bsart werks aktiv
           banf first_mail z1st_email
           z2nd_email z3rd_email
           FROM zmm_email_pa_t
           INTO TABLE gt_zmm_email_pa_t
           FOR ALL ENTRIES IN gt_ekko_fin
           WHERE aktiv = gc_check AND
                 bsart = gt_ekko_fin-bsart AND
                 werks = gt_ekko_fin-werks.
    IF sy-subrc EQ 0.
      SORT gt_zmm_email_pa_t BY bsart werks.
    ENDIF.

  ENDIF.

**For the Documents whose plants and documents types are maintained in the table ZMM_EMAIL_AF_T
**check if flag BANF (Only with PR) is checked and then proceed to check if PR number is available
**for the same .
  SORT : gt_ekko_fin BY bsart werks.
  CLEAR : gs_wa_ekko_fin.
  LOOP AT gt_ekko_fin INTO gs_wa_ekko_fin.
    READ TABLE gt_zmm_email_pa_t INTO gs_wa_zmm_email_pa_t
                                 WITH KEY bsart = gs_wa_ekko_fin-bsart
                                          werks = gs_wa_ekko_fin-werks
                                          BINARY SEARCH.
    IF sy-subrc EQ 0.
      IF gs_wa_zmm_email_pa_t-banf = gc_check.
        IF gs_wa_ekko_fin-banfn IS NOT INITIAL.
          APPEND gs_wa_ekko_fin TO gt_ekko_fin2.
          APPEND gs_wa_zmm_email_pa_t TO gt_zmm_email_pa_t2.
        ENDIF.
      ELSE.
        APPEND gs_wa_ekko_fin TO gt_ekko_fin2.
        APPEND gs_wa_zmm_email_pa_t TO gt_zmm_email_pa_t2.
      ENDIF.
    ENDIF.
  ENDLOOP.

Thanks & Regards,

Chirag

2 REPLIES 2
Read only

Former Member
0 Likes
464

Hi Chirag,

Try this..

Create an internal table of type SELOPT.

data: it_range type table of SELOPT,

        wa_range type selopt.

clear wa_range.

wa_range-sign = 'I'.

wa_range-option = 'CP' .  " Contains Pattern

wa_range-low = DE1*.

append wa_range to it_range.

clear wa_range.

wa_range-sign = 'I'.

wa_range-option = 'CP' .  " Contains Pattern

wa_range-low = *E14.

append wa_range to it_range.

In Select query:

Select <fields> from <table> into table <object> where werks in it_range.

Try this and post your doubts.

Thanks,

Manikandan JN.

Read only

Former Member
0 Likes
463

Hi Chirag,

Is this not what you are looking for..? If you still have some queries, just post it. I will help you get the correct answer.

Thanks,

Manikandan JN.