Very Urgent : Reterival of AWKEY field from BKPF table

Hi,
I am making a report in which i have to make relation of 2 fields BKPF-AWKEY and MKPF-MBLNR . but the problem is i am not to reterive data from it as i have to make inner join among these fields so data can be reterived fmo these tables.
plz provide me some guidelines as it is really urgent to me and help will be deinfately rewarded.

First and foremost, i would advice you not to use words like VERY URGENT in your subject. You might want to go through the following link to understand the basic rules of the forum:
[Rules of Engagement|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]
For your requirement, below code might help you understand the logic in determining the link between BKPF and MKPF.
TYPES: BEGIN OF t_bkpf,
         bukrs type bukrs,
         belnr type belnr_d,
         gjahr TYPE gjahr,
         awtyp type awtyp,
         awkey type awkey,
        end of t_bkpf.
types: begin of t_mkpf,
         mblnr type mblnr,
         mjahr type mjahr,
       end of t_mkpf.
data: i_bkpf type STANDARD TABLE OF t_bkpf,
      i_mkpf type STANDARD TABLE OF t_mkpf.
data: wa_bkpf type t_bkpf,
      wa_mkpf type t_mkpf.
PARAMETERS: p_bukrs type bukrs OBLIGATORY,
            p_gjahr TYPE gjahr OBLIGATORY.
START-OF-SELECTION.
  SELECT bukrs belnr gjahr awtyp awkey
    into table i_bkpf
    from bkpf
    UP TO 20 ROWS
    where bukrs = p_bukrs
    and   gjahr = p_gjahr
    and   awtyp = 'MKPF'.
IF NOT i_bkpf[] is INITIAL.
   select mblnr mjahr from mkpf into table i_mkpf
      for ALL ENTRIES IN i_bkpf
     where mblnr = i_bkpf-awkey(10).
*     and   mjahr = i_bkpf-awkey+10(4).
ENDIF.
LOOP AT i_bkpf into wa_bkpf.
  READ TABLE i_mkpf into wa_mkpf
    with key mblnr = wa_bkpf-awkey(10)
             mjahr = wa_bkpf-awkey+10(4).
  IF sy-subrc eq 0.
     write:/ 'Accounting Document:', 23 wa_bkpf-belnr,
          35 'Material Document:', 55 wa_mkpf-mblnr.
  ENDIF.
ENDLOOP.

Similar Messages

  • Get FI Documet number from BKPF table using CO document number in COVP tabl

    Hi,
    In  datasource 0CO_OM_CCA_9 , we have written a code in CMOD to get the FI Document Number from CO document Number.
    The flow of code is:
    1) From the CO document number, get reference document number  (REFBNfield) from, COVP table
    2) Pass this REFBN in AWKEY(10) field of BKPF table.
    3) We have created new field in datasource named 'ZBELRE' which gets populated with BELNR field obtained from BKPF table.
    This ZBELNR is the FI Document number.
    But somehow wrong FI Document number is getting populated.
    After analyzing code, we found that the AWKEY which we passed in BKPF table is incomplete and the full AWKEY is
    COVP-REFBN+COVP-AWORG
    Is this condition always remains true in all the cases? Also, is the selection criterion which we have used to find the FI document number from BKPF table is sufficient?
    Our CO Consultant says that we should also pass AWTYP along with AWKEY in BKPF table.
    Please suggest a solution.
    Following is the code :
    ***********Datasource Modification for0CO_OM_CCA_9*******************
      WHEN '0CO_OM_CCA_9'." Data Source
        TYPES:BEGIN OF ty_bkpf,
        belnr TYPE bkpf-belnr,
        xblnr TYPE bkpf-xblnr,
        bktxt TYPE bkpf-bktxt,
        awkey TYPE bkpf-awkey,
        bukrs TYPE bkpf-bukrs,
        gjahr TYPE bkpf-gjahr,
        END OF ty_bkpf.
        TYPES : BEGIN OF ty_bseg1,
        lifnr TYPE bseg-lifnr,
        belnr TYPE bseg-belnr,
        bukrs TYPE bseg-bukrs,
        gjahr TYPE bseg-gjahr,
        END OF ty_bseg1.
        DATA: it_bkpf TYPE STANDARD TABLE OF ty_bkpf,
        wa_bkpf TYPE ty_bkpf,
        it_bseg1 TYPE STANDARD TABLE OF ty_bseg1,
        wa_bseg1 TYPE ty_bseg1,
        l_s_icctrcsta1 TYPE icctrcsta1.
        "Extract structure for Datasoure 0co_om_cca_9.
        DATA: l_awkey TYPE bkpf-awkey.
        DATA: l_gjahr1 TYPE gjahr.
        DATA: len TYPE i,
        l_cnt TYPE i.
        l_cnt = 10.
        SELECT lifnr
        belnr
        bukrs
        gjahr
        FROM bseg
        INTO TABLE it_bseg1.
        DELETE ADJACENT DUPLICATES FROM it_bseg1 COMPARING belnr gjahr .
        SELECT belnr
        xblnr
        bktxt
        awkey
        bukrs
        gjahr
        FROM bkpf
        INTO TABLE it_bkpf.
        IF sy-subrc EQ 0.
          CLEAR: l_s_icctrcsta1,
          wa_bkpf,
          l_awkey,
          wa_bseg1.
          LOOP AT c_t_data INTO l_s_icctrcsta1.
            MOVE l_s_icctrcsta1-fiscper(4) TO l_gjahr1.
            READ TABLE it_bkpf INTO wa_bkpf WITH KEY awkey(10) =
            l_s_icctrcsta1-refbn
            gjahr = l_gjahr1.
            IF sy-subrc EQ 0.
              MOVE wa_bkpf-belnr TO l_s_icctrcsta1-zzbelnr.
              MOVE wa_bkpf-xblnr TO l_s_icctrcsta1-zzxblnr.
              MOVE wa_bkpf-bktxt TO l_s_icctrcsta1-zzbktxt.
              MODIFY c_t_data FROM l_s_icctrcsta1.
              READ TABLE it_bseg1 INTO wa_bseg1
              WITH KEY
              belnr = wa_bkpf-belnr
              bukrs = wa_bkpf-bukrs
              gjahr = wa_bkpf-gjahr.
              IF sy-subrc EQ 0.
                MOVE wa_bseg1-lifnr TO l_s_icctrcsta1-lifnr.
                MODIFY c_t_data FROM l_s_icctrcsta1.
                CLEAR: l_s_icctrcsta1,
                wa_bseg1,
                l_gjahr1.
              ENDIF.
            ENDIF.
            CLEAR: l_s_icctrcsta1.
          ENDLOOP.
        ENDIF.
    ***End of Datasource Modification for 0CO_OM_CCA_9*******************

    Hi,
    this forum is for the SAP BusinessObjects BI Solution Architecture. Please post your question into the corresponding product forum for SPA BW
    regards
    Ingo Hilgefort

  • Write fields from two tables in one line??

    Hi friends,
    I want to write some fields from bkpf and bseg in one line...
    My report should like something like this:
    ****some text*****
    *for first document*******  bkpf-bldat  kunnr  bseg-belnr    bseg-gsber   bseg-wrbtr     
    *for second document***  bkpf-bldat  kunnr  bseg-belnr    bseg-gsber   bseg-wrbtr     
    *for third document******  bkpf-bldat  kunnr  bseg-belnr    bseg-gsber   bseg-wrbtr  
    etc.
    What should I change in order to get this form in report output?? Can I put these fields in some table so that it looks like excel table??Could you please check out the code below?
      loop at it_bkpf into wa_bkpf.
      loop at it_bseg into wa_bseg.
      write: wa_bseg-gsber, wa_bseg-belnr, wa_bseg-wrbtr.
      endloop.
      write: wa_bkpf-bldat.
      read table it_bsid with key bukrs = wa_bkpf-bukrs
      belnr = wa_bkpf-belnr
      gjahr = wa_bkpf-gjahr
      cpudt = wa_bkpf-cpudt.
      if sy-subrc = 0.
      write: it_bsid-kunnr.
      endif.
      endloop.
    Thanks,
    Nihad

    hi nihad,
    define positions on where to write data like this.
    LOOP AT it_bkpf INTO wa_bkpf.
      LOOP AT it_bseg INTO wa_bseg WHERE belnr EQ wa_bkpf-belnr.
        WRITE: /5 wa_bkpf-bldat.
        READ TABLE it_bsid
        WITH KEY bukrs = wa_bkpf-bukrs
                         belnr = wa_bkpf-belnr
                         gjahr = wa_bkpf-gjahr
                         cpudt = wa_bkpf-cpudt.
        IF sy-subrc EQ 0.
           WRITE: 20 it_bsid-kunnr.
        ENDIF.
        WRITE: 35 it_bseg-belnr,
                    50 it_bseg-gsber,
                    60 it_bseg-wrbtr.
      ENDLOOP.
    ENDLOOP.
    regards,
    Peter

  • How to print the data  if we take different fields from diffrent tables

    Hi ABAPers,
    I take diff fields from 3 tables. Those are
    these fields from EKBE
           EBELN
           EBELP
           BELNR
           BUZEI
           BWART
           BUDAT
           AREWR
           REEWR
           WERKS
           MWSKZ
    these fields from EKKO
           BUKRS
           BSART
           WAERS
    these field from EKPO
           TXZ01
           MATNR
           MTART
    I want to print the data all fields.What logic can i write?
    Please help me for this question and i am waiting for your response.
    Regards,
    Raja Sekhar.

    Hi,
    First you have to fetch data from all the three tables and then consolidate into final table.
    In Declaration:
    1.Declare Internal Table for EKKO holding:
    EBELN
    BUKRS
    BSART
    WAERS
    2.Declare Internal Table for EKPO holding:
    EBELN
    EBELP
    TXZ01
    MATNR
    MTART
    3.Declare Internal Table for EKBe holding:
    EBELN
    EBELP
    BELNR
    BUZEI
    BWART
    BUDAT
    AREWR
    REEWR
    WERKS
    MWSKZ
    *==> This table has
    MANDT
    EBELN
    EBELP
    ZEKKN
    VGABE
    GJAHR
    BELNR
    BUZEI
    as Primary keys field,you should have values for all the PK aotherwise you will get multiple entries*
    4.Declare a Final Internal Table i_final with all the fields you want
    EBELN
    EBELP
    BUKRS
    BSART
    WAERS
    TXZ01
    MATNR
    MTART
    BELNR
    BUZEI
    BWART
    BUDAT
    AREWR
    REEWR
    WERKS
    MWSKZ
    Data Fetching
    select EBELN
    BUKRS
    BSART
    WAERS
    from EKKO
    into table i_ekko
    where .........<selection criteria>.
    if not i_ekko is initial.
    select EBELN
    EBELP
    TXZ01
    MATNR
    MTART
    from EKPO
    into table i_ekpo
    for all entries in i_ekko
    where EBELN = I_EKKO-EBELN
    AND ......<If any other selection criteria>.
    if not i_ekpo is initial.
    select EBELN
    EBELP
    BELNR
    BUZEI
    BWART
    BUDAT
    AREWR
    REEWR
    WERKS
    MWSKZ
    from EKBE
    into table i_ekbe
    for all entries in i_ekpo
    where ebeln = i_ekpo-ebeln
    and ebelp = i_ekpo-ebelp
    and ..........<If any othet selection criteria>
    endif.
    endif.
    Consolidate
    sort i_ekko by ebeln.
    sort i_ekpo by ebeln ebelp.
    sort i_ekbe by ebeln ebelp.
    LOOP AT i_ekbe into wa_ekbe.
    read table i_ekko into wa_ekko with key ebeln = wa_ekbe-vbeln binary search.
    if sy-subrc = 0.
    ====>Move all the required firlds from I_EKKO to i_final  , like
    wa_final-BUKRS = wa_ekko-BUKRS.
    endif.
    read table i_ekpo into wa_ekpo with key ebeln = wa_ekbe-vbeln
    ebelp = wa_ekbe-ebelp binary search.
    if sy-subrc = 0.
    ====>Move all the required firlds from I_EKPO to i_final  , like
    wa_final-EBELP = wa_ekko-EBELP.
    wa_final-TXZ01 = wa_ekko-TXZ01.
    endif.
    ==>Also all the required fields from EKBE to final table, like
    wa_final-BELNR = wa_ekbe-BELNR.
    endloop.

  • I need to add a single field from with_item table . need to write select query with reference to company code , account doc no , fiscal year

    I need to add a single field from with_item table . need to write select query with reference to company code , account doc no , fiscal year

    Hi Arun ,
    Can you explain little bit more ??
    what is account doc no? 
    what are the transactions should be displayed in your output??
    -Rajesh N

  • No records when inputting new field from linked tables.

    I have linked two tables in a report.  If I use only fields from one table, no problem.  As soon as I add a field from the other table no records are pulled.  I am using the same filed "IncidentID" in both tables as a link.  If I attempt to pull the "IncidentID" from the second table no records are pulled.  There does not appear to be any key fields or indexes in either table if that helps.

    Here are the SQL queries.  The first string is without any fields from "WorkLog".  The second is after adding the field "WorkLog.Incident Number" to the form.
    SELECT "HPD_Help_Desk"."Incident Number", "HPD_Help_Desk"."Reported Date", "HPD_Help_Desk"."Direct Contact Site", "HPD_Help_Desk"."Assignee", "HPD_Help_Desk"."Status", "HPD_Help_Desk"."Last Modified Date", "HPD_Help_Desk"."Description", "HPD_Help_Desk"."Priority"
    FROM   "HPD:Help Desk" "HPD_Help_Desk"
    WHERE  "HPD_Help_Desk"."Status"='Pending' AND ("HPD_Help_Desk"."Assignee"='Debbie Kiolbasa' OR "HPD_Help_Desk"."Assignee"='John L King' OR "HPD_Help_Desk"."Assignee"='Ligaya Plumlee' OR "HPD_Help_Desk"."Assignee"='Ryan Keeler')
    ORDER BY "HPD_Help_Desk"."Assignee"
    SELECT "HPD_Help_Desk"."Incident Number", "HPD_Help_Desk"."Reported Date", "HPD_Help_Desk"."Direct Contact Site", "HPD_Help_Desk"."Assignee", "HPD_Help_Desk"."Status", "HPD_Help_Desk"."Last Modified Date", "HPD_Help_Desk"."Description", "HPD_Help_Desk"."Priority", "HPD_WorkLog"."Incident Number"
    FROM   "HPD:Help Desk" "HPD_Help_Desk" INNER JOIN "HPD:WorkLog" "HPD_WorkLog" ON ("HPD_Help_Desk"."Incident Number"="HPD_WorkLog"."Incident Number") AND ("HPD_Help_Desk"."InstanceId"="HPD_WorkLog"."InstanceId")
    WHERE  "HPD_Help_Desk"."Status"='Pending' AND ("HPD_Help_Desk"."Assignee"='Debbie Kiolbasa' OR "HPD_Help_Desk"."Assignee"='John L King' OR "HPD_Help_Desk"."Assignee"='Ligaya Plumlee' OR "HPD_Help_Desk"."Assignee"='Ryan Keeler')
    ORDER BY "HPD_Help_Desk"."Assignee"
    BTW - The "Left Outer Join" receives the errors noted in above post whereas the default "Inner Join" just comes back with empty records.
    Unable to use the third party tools due to restrictions on loading software.  Also we are unable to access the lower level database.
    Thanks

  • SAP GRC 10.1 AMF No data selected when adding duplicate fields from separate tables for configurable data sources

    Hi There,
    In SAP GRC 10.0, our team had an issue where we could not add duplicate fields from separate table (see ERROR: Select Currency/UoM field for the selected analyzed fields). This was resolved by the SAP Note 1904313/ 1904314 (http://service.sap.com/sap/support/notes/1904313).
    We upgraded our system to SAP GRC 10.1 SP05 and could now add the duplicate fields from separate tables. SAP Note 1904313/ 1904314 was part of SAP GRC 10.1 SP03 so it makes sense that we, in a higher version (SP05), would be able to do this.
    The issue now is when we add the duplicate fields from different tables and run the Ad-hoc Query to test if the data source works correctly, the No Data Selected warning persists. This means that the data source provides no data for analysis, which is required to write our business rules.
    Below is an example:
    Basic data source with just one currency reference field EBAN-WAERS.
    When you run the Ad-Hoc Query you receive data.
    Basic data source with second currency reference field EKKO-WAERS.
    When you run the Ad-Hoc Query no data is found.
    Please also make reference to the following thread logged by my colleague (ERROR: Select Currency/UoM field for the selected analyzed fields)
    Any assistance to receive data with duplicate fields from separate tables will be highly appreciated.
    Thanking you in advance.
    Regards
    Gary Khan

    Hi
    following are the  error messages from dump
    hrtText
       There is already a line with the same key.
    hat happened?
       Error in ABAP application program.
       The current ABAP program "SAPLCKMS" had to be terminated because one of the
       statements could not be executed.
       This is probably due to an error in the ABAP program.
    rror analysis
       You wanted to add an entry to table "\FUNCTION-POOL=CKMS\DATA=T_DYN_CKMLCR",
        which you declared
       with a UNIQUE KEY. However, there was already an entry with the
       same key.
       This may have been in an INSERT or MOVE statement, or within a
       SELECT ... INTO statement.
       In particular, you cannot insert more than one initial line into a
       table with a unique key using the INSERT INITIAL LINE... statement.
    rigger Location of Runtime Error
       Program                                 SAPLCKMS
       Include                                 LCKMSF01
       Row                                     226
       Module type                             (FORM)
       Module Name                             DYNAMIC_PERIOD_CLOSING
    Source code where dump ocured
    222
    223           APPEND ht_ckmlpp TO t_add_ckmlpp.
    224           APPEND LINES OF ht_ckmlcr TO t_add_ckmlcr.
    225           INSERT ht_ckmlpp INTO TABLE t_dyn_ckmlpp.
    >>>>           INSERT LINES OF ht_ckmlcr INTO TABLE t_dyn_ckmlcr.
    227         ENDWHILE.
    Also I guess there is problem with material ledger in R/3 side
    I have never worked on material ledger before so dont hav idea of Tcode and tables in SAP R/3 for material ledger.
    Thanks
    Navneet

  • Drop down in the selection for the field from the table

    Hi.
    i want to put the drop down for the field from the table fo which i dont know the number of entries for the field zregion1 of the table zbwcntry.
    please tell me how to use the function module and what could be the line of codes.
    the drop down is for the select option on the slection screen of the classical report.
    please help .

    HI,
    Check below code..it may help you.
    REPORT Zbunu .
    TYPES :BEGIN OF STR ,
           MATNR TYPE MATNR ,
           END OF STR .
    DATA : ITAB TYPE TABLE OF STR WITH HEADER LINE,
           VAR TYPE MARA-MATNR .
    PARAMETERS : S_MATNR TYPE MATNR ,
                  P_MATNR TYPE MATNR.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_MATNR .
    SELECT MATNR FROM MARA INTO
    CORRESPONDING FIELDS OF TABLE ITAB UP TO 1000 ROWS.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
      EXPORTING
      DDIC_STRUCTURE         = ' '
        retfield               = 'MATNR'
      PVALKEY                = ' '
       DYNPPROG               = SY-CPROG
       DYNPNR                 = SY-DYNNR
       DYNPROFIELD            = 'S_MATNR'
      STEPL                  = 0
      WINDOW_TITLE           =
      VALUE                  = ' '
       VALUE_ORG              = 'S'
      MULTIPLE_CHOICE        = ' '
      DISPLAY                = 'X'
      CALLBACK_PROGRAM       = ' '
      CALLBACK_FORM          = ' '
      tables
        value_tab              = ITAB
      FIELD_TAB              =
      RETURN_TAB             =
      DYNPFLD_MAPPING        =
    EXCEPTIONS
       PARAMETER_ERROR        = 1
       NO_VALUES_FOUND        = 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.
    Regards
    Ansumesh

  • Bus.transaction field in BKPF Table

    Hello SAP Gurus!
    I would like to get some info on Bus.transaction field in BKPF Table.
    How does this field gets populated?
    What does it signify and its functionality?
    Is there any config in SAP to control this field?
    Thanks for your reply in advance,
    Senthil

    Hi
    Refer to this link
    http://www.sap-img.com
    pushkaraj

  • I NEED FIELDS FROM VBFA TABLE

    HI ALL,
    I NEED FIELDS FROM VBFA TABLE
    THE FIELDS I WANT IS :
    CUSTOMER-ID
    CUSTOMER NAME
    CONTACT NAME
    PROJECTID
    ORDER NO
    SALES MAN ID
    ORDER PROCESS DATE
    INVOICE DATE
    GROSS AMOUNT
    NET AMOUNT POSTAL CODE.
    THANKS & REGARDS,
    R.VINOD.

    Hi Vinod..
    Try this Code. I made all the modifications in your code .. It will solve ur issues..
    REPORT zsdr_omvsa40.
    TYPE-POOLS
    TYPE-POOLS: slis.
    TABLE DECLARATIONS
    TABLES : vbak, vbkd,
    zzvbak,
    kna1, vbrk, vbrp, knvp .
    INTERNALTABLE DECLARATION *
    DATA: BEGIN OF i_vbak OCCURS 0,
    vbelv LIKE vbfa-vbelv, " Sales Order no
    vbeln like vbfa-vbeln, "Invoice No
    erdat LIKE vbak-erdat, " Date on Which Record Was Created
    kunnr LIKE vbak-kunnr,
    ps_psp_pnr LIKE vbak-ps_psp_pnr, " Work Breakdown Structure Element
    END OF i_vbak.
    *DATA : BEGIN OF i_zzvbak OCCURS 0,
    *vbeln LIKE zzvbak-vbeln,
    *zssidc LIKE zzvbak-zssidc, "Salesman ID
    *END OF i_zzvbak.
    DATA : BEGIN OF i_vbrk OCCURS 0,
    vbeln LIKE vbrk-vbeln,
    fkdat LIKE vbrk-fkdat, "Invoice Date
    END OF i_vbrk.
    DATA : BEGIN OF i_kna1 OCCURS 0,
    kunnr LIKE kna1-kunnr , " Customer Number 1
    name1 LIKE kna1-name1, " Customer Name
    pstlz LIKE kna1-pstlz , " Postal Code
    END OF i_kna1.
    DATA : BEGIN OF i_vbrp OCCURS 0,
    vbeln LIKE vbrp-vbeln,
    aubel LIKE vbrp-aubel,
    netwr LIKE vbrp-netwr , " Net Value in Document Currency
    kzwi1 LIKE vbrp-kzwi1, " Subtotal 1 from pricing procedure for condition
    erdat LIKE vbrp-erdat, "Billing document.
    END OF i_vbrp.
    DATA : BEGIN OF i_knvp OCCURS 0,
    parvw LIKE knvp-parvw , " Partner Function
    kunnr LIKE knvp-kunnr ,
    parnr LIKE knvp-parnr , " Number of contact person
    END OF i_knvp .
    DATA : BEGIN OF i_data OCCURS 0,
    erdat LIKE vbak-erdat, " Date on Which Record Was Created
    vbeln LIKE vbak-vbeln, " Sales Order no
    fkdat LIKE vbrk-fkdat, " Invoice date.
    kunnr LIKE kna1-kunnr , " Customer Number
    ps_psp_pnr LIKE vbak-ps_psp_pnr, " Work Breakdown Structure Element
    name1 LIKE kna1-name1, " Customer Name
    netwr LIKE vbrp-netwr , " Net Value in Document Currency
    kzwi1 LIKE vbrp-kzwi1, " Subtotal 1 from pricing procedure for condition
    parvw LIKE knvp-parvw , " Partner Function
    parnr LIKE knvp-parnr , " Number of contact person
    *zssidc LIKE zzvbak-zssidc, "Salesman ID
    pstlz LIKE kna1-pstlz , " Postal Code
    END OF i_data.
    ALV Declaraton
    DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
    gd_tab_group TYPE slis_t_sp_group_alv,
    gd_layout TYPE slis_layout_alv,
    it_listheader TYPE slis_t_listheader,
    gd_repid LIKE sy-repid.
    Selection - Screen
    SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS creation FOR vbak-erdat . " Sales Order Date
    SELECT-OPTIONS period FOR vbrk-fkdat . " Invoice Date
    SELECT-OPTIONS order FOR vbak-vbeln . " Sales order no
    SELECT-OPTIONS name FOR kna1-name1 . " Customer Name
    SELECT-OPTIONS contact FOR knvp-parnr . " Contact Name.
    *SELECT-OPTIONS ssid FOR zzvbak-zssidc . " Salesman ID
    SELECT-OPTIONS project FOR vbak-ps_psp_pnr . " Work Breakdown Structure Element
    SELECTION-SCREEN : END OF BLOCK b1.
    START-OF-SELECTION
    START-OF-SELECTION.
      PERFORM data_retrieval.
      PERFORM build_fieldcatalog.
    PERFORM BUILD_LAYOUT.
    PERFORM top_of_page.
      PERFORM fill_listheader USING it_listheader.
      PERFORM display_alv_report.
    END-OF-SELECTION.
    *TOP-OF-PAGE.
    TOP-OF-PAGE.
    END-OF-PAGE.
    *& Form BUILD_FIELDCATALOG
    text
    FORM build_fieldcatalog.
      fieldcatalog-fieldname = 'KUNNR'.
      fieldcatalog-seltext_m = 'Sold to Party'.
      fieldcatalog-col_pos = 0.
      fieldcatalog-outputlen = 10.
      fieldcatalog-emphasize = 'X'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR fieldcatalog.
      fieldcatalog-fieldname = 'NAME1'.
      fieldcatalog-seltext_m = 'Hlev Customer'.
      fieldcatalog-col_pos = 1.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR fieldcatalog.
      fieldcatalog-fieldname = 'PARNR'.
      fieldcatalog-seltext_m = 'Contact name'.
      fieldcatalog-col_pos = 2.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR fieldcatalog.
      fieldcatalog-fieldname = 'PS_PSP_PNR'.
      fieldcatalog-seltext_m = 'Project ID'.
      fieldcatalog-col_pos = 3.
      fieldcatalog-do_sum = 'X'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR fieldcatalog.
      fieldcatalog-fieldname = 'VBELN'.
      fieldcatalog-seltext_m = 'Sales Document Type'.
      fieldcatalog-col_pos = 4.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR fieldcatalog.
      fieldcatalog-fieldname = 'ZSSIDC'.
      fieldcatalog-seltext_m = 'SSID'.
      fieldcatalog-col_pos = 5.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR fieldcatalog.
      fieldcatalog-fieldname = 'ERDAT'.
      fieldcatalog-seltext_m = 'so date'.
      fieldcatalog-col_pos = 6.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR fieldcatalog.
      fieldcatalog-fieldname = 'FKDAT'.
      fieldcatalog-seltext_m = 'inv date'.
      fieldcatalog-col_pos = 7.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR fieldcatalog.
      fieldcatalog-fieldname = 'KWZI1'.
      fieldcatalog-seltext_m = 'gross amt'.
      fieldcatalog-col_pos = 8.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR fieldcatalog.
      fieldcatalog-fieldname = 'NETWR'.
      fieldcatalog-seltext_m = 'net amt'.
      fieldcatalog-col_pos = 9.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR fieldcatalog.
      fieldcatalog-fieldname = 'PSTLZ'.
      fieldcatalog-seltext_m = 'Postal code'.
      fieldcatalog-col_pos = 10.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR fieldcatalog.
    ENDFORM. "BUILD_FIELDCATALOG
    *& Form DATA_RETRIEVAL
    text
    FORM data_retrieval.
      SELECT VBFAvbelv VBFAvbeln
             VBAKerdat VBAKkunnr VBAK~ps_psp_pnr
             INTO TABLE i_vbak
      FROM VBFA
      INNER JOIN vbak
      ON VBFAVBELV = VBAKVBELN
      WHERE VBAK~erdat IN creation
      AND VBFA~vbelV IN ORDER
      AND VBAK~ps_psp_pnr IN project
      AND VBFA~VBTYP_N = 'M'  "Subsequent doc is Invoice
      AND VBFA~VBTYP_V = 'C'  "Prec doc is Sales order
      IF NOT i_vbak[] IS INITIAL.
    **Change of ORDER in SELECTS HERE
        SELECT vbeln fkdat FROM vbrk INTO TABLE i_vbrk
        FOR ALL ENTRIES IN i_vbak
        WHERE vbeln = i_vbak-vbeln
        AND fkdat IN period.
        IF NOT i_vbrk[] IS INITIAL.
          SELECT vbeln aubel netwr kzwi1 FROM vbrp INTO TABLE i_vbrp
          FOR ALL ENTRIES IN i_vbrk
          WHERE VBELN = i_vbrk-vbeln.
        endif.
        SELECT kunnr name1  pstlz  FROM kna1 INTO TABLE i_kna1 FOR ALL ENTRIES IN i_vbak
        WHERE kunnr = i_vbak-kunnr
        AND name1 IN name.
    *SELECT vbeln zssidc FROM zzvbak INTO TABLE i_zzvbak FOR ALL ENTRIES IN i_vbak
    *WHERE vbeln = i_vbak-vbeln
    *AND zssidc IN ssid .
    select netwr kzwi1 erdat from vbrp into table i_vbrp for all entries in i_vbak
    where erdat = i_vbak-erdat.
        SELECT kunnr parnr parvw FROM knvp INTO CORRESPONDING FIELDS OF TABLE i_knvp FOR ALL ENTRIES IN i_vbak
        WHERE kunnr = i_vbak-kunnr
        AND parvw = 'AP'
        AND parnr IN contact.
      ENDIF .
      SORT I_VBAK BY VBELN .
      SORT I_VBRK BY VBELN .
      LOOP AT i_vbrp.  "Invoice Item data
        MOVE i_vbrp-netwr TO i_data-netwr .
        MOVE i_vbrp-kzwi1 TO i_data-kzwi1.
        READ table I_VBAK WITH KEY VBELN = I_VBRP-VBELN BINARY SEARCH.  "Sales Order info
        IF SY-SUBRC = 0.
          MOVE I_VBAK-VBELV TO I_DATA-VBELN.   "Sales Order no
          MOVE I_VBAK-erdat TO I_DATA-erdat.   " Date on Which Record Was Created
          MOVE I_VBAK-kunnr TO I_DATA-KUNNR.    "Customer No
          MOVE I_VBAK-ps_psp_pnr TO I_DATA-ps_psp_pnr. " Work Breakdown Structure Element
        endif.
        READ TABLE I_VBRK WITH KEY VBELN = I_VBRP-VBELN BINARY SEARCH.   "Invoice header info
        IF SY-SUBRC = 0.
          MOVE i_vbrk-fkdat TO i_data-fkdat.
        endif.
        READ TABLE I_KNA1 WITH KEY KUNNR = I_VBAK-KUNNR BINARY SEARCH.   "Customer info
        IF SY-SUBRC = 0.
          MOVE i_kna1-kunnr TO i_data-kunnr.
          MOVE i_kna1-name1 TO i_data-name1.
          MOVE i_kna1-pstlz TO i_data-pstlz .
        endif.
        READ TABLE I_KNvp WITH KEY KUNNR = I_VBAK-KUNNR BINARY SEARCH.   "Partner info
        IF SY-SUBRC = 0.
          MOVE i_knvp-parnr TO i_data-parnr.
        endif.
        APPEND i_data.
      ENDLOOP.
    ENDFORM. "DATA_RETRIEVAL
    *& Form DISPLAY_ALV_REPORT
    text
    FORM display_alv_report.
    GD_REPID = SY-REPID.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER = ' '
    I_BUFFER_ACTIVE = ' '
      i_callback_program = sy-repid
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = ' '
      i_callback_top_of_page = 'TOP_OF_PAGE'
    I_CALLBACK_HTML_TOP_OF_PAGE = ' '
    I_CALLBACK_HTML_END_OF_LIST = ' '
    I_STRUCTURE_NAME =
    I_BACKGROUND_ID = ' '
    I_GRID_TITLE =
    I_GRID_SETTINGS =
    IS_LAYOUT =
      it_fieldcat = fieldcatalog[]
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
    IT_EVENTS =
    IT_EVENT_EXIT =
    IS_PRINT =
    IS_REPREP_ID =
    I_SCREEN_START_COLUMN = 0
    I_SCREEN_START_LINE = 0
    I_SCREEN_END_COLUMN = 0
    I_SCREEN_END_LINE = 0
    I_HTML_HEIGHT_TOP = 0
    I_HTML_HEIGHT_END = 0
    IT_ALV_GRAPHICS =
    IT_HYPERLINK =
    IT_ADD_FIELDCAT =
    IT_EXCEPT_QINFO =
    IR_SALV_FULLSCREEN_ADAPTER =
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
      TABLES
      t_outtab = i_data.
    EXCEPTIONS
    PROGRAM_ERROR = 1
    OTHERS = 2 .
    *IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ENDIF.
    ENDFORM. "DISPLAY_ALV_REPORT
    FORM FOR FILLING LISTHEADER *
    FORM fill_listheader USING it_listheader TYPE slis_t_listheader.
      DATA : wa_listheader TYPE slis_listheader.
      wa_listheader-typ = 'H'.
      wa_listheader-info = 'Noel Gifts International Limited '.
      APPEND wa_listheader TO it_listheader.
      wa_listheader-typ = 'S'.
      wa_listheader-info = 'CUSTOMER CREDIT EXCEPTION REPORT' .
      APPEND wa_listheader TO it_listheader.
      CLEAR wa_listheader.
    ENDFORM. "fill_listheader
    *& Form top_of_page
    text
    FORM top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = it_listheader.
    ENDFORM. "top_of_page
    REWARD IF HELPFUL.

  • Fetch only required fields from SQL Table

    Hi,
    We have a table like below which will get data thru a job.
    And I'm writing a Job/SP which will fetch 4 fields from that table and send  them in a Email to Admins informing how many new employee are added newly.
    How to loop thru these fields  and not only there might be a chance where we will have 100 records and I need to take only first 30 of them and send.
    EmpId
    Empname
    Deptname
    Designation
     Can any one has any solution on achieving this?
    Thanks

    Please refer the below link:
    http://beyondrelational.com/modules/2/blogs/77/posts/11386/sql-server-t-sql-different-ways-to-generate-a-comma-separated-string-from-a-table.aspx
    You need to use the Top30 query as your table in the script :
    select top 30 EmpID,EmpName,DeptName,Designation
    from tbl_name
    order by EmpID
    Eg: You may need to do for other columns:
    --WARNING: THIS SCRIPT IS PROVIDED AS-IS AND WITHOUT
    -- WARRANTY.
    -- FOR DEMONSTRATION PURPOSES ONLY
    --Step 01: Generate Temp table to store source data
    DECLARE @NamesTable TABLE (Id INT,
    Name NVARCHAR(50))
    --Step 02: Generate test data
    INSERT INTO @NamesTable VALUES (1,'A'),
    (2,'D'),
    (2,'C'),
    (3,'E'),
    (3,'H'),
    (3,'G')
    DECLARE @listIds VARCHAR(MAX) --DO NOT initialize this one!
    SELECT @listIds = COALESCE(@listIds + ',' ,'') + Cast(nt.Id as varchar(10))
    FROM @NamesTable nt Order by ID asc
    DECLARE @listNames VARCHAR(MAX) --DO NOT initialize this one!
    SELECT @listNames = COALESCE(@listNames + ',' ,'') + nt.Name
    FROM @NamesTable nt Order by ID asc
    SELECT 'EmpID: ' + @listIds+', EmpName: ' + @listNames

  • How we can use  XREF1_HD field of BKPF table.

    Hi,
    How we can use  XREF1_HD field of BKPF table.
    Ritu Verma

    Hello,
    Sadashivan is absolutely right.
    You can update this field while posting with using standart substitution or using Business transaction event 00001120.
    If you use BAPI_ACC_DOCUMENT_POST and want to fill this fields, you can use RWBAPI01 business transaction event also.
    Regards,
    Burak

  • Read contents of changing fields from internal table

    Hi Folks,
    Please help me in my query below:
    Consider there is a Z-table with two fields TABNAM and FIELD having values KNA1 and NAME1 respectively.
    In my report I have fetched entries for customers from KNA1. Now based on the field from Z-table I want to populate a variable suppose V_FREE_VAR with the value from KNA1 table.
    Here V_FREE_VAR is of CHAR200 so that it accomodate all types of values from KNA1.
    The value of Z-table FIELD can change daily i.e next day the value may be PSTLZ.
    So how can I read the particular field from internal table as the field to be read is dynamic.
    Note: using case is not feasible.
    Thanks in advance.
    Regards,
    Shardul

    @Hartmut P
    As Rob said i want to get the value of the field from internal table. the code is something like this.
    I_KNA1 contains records for customers.
    Suppose values of Z-table are in internal table I_TEMP_TABLE.
    Entries in I_TEMP_TABLE are as follows
    TABNAME      FIELDNAME
    KNA1                 NAME1
    The value of FIELNAME in Z-table can be changed
    Loop at I_TEMP_TABLE into WA_TEMP_TABLE.
    Read I_KNA1 into WA_KNA1 with key KUNNR = '0001002234'.
    IF SY-SUBRC EQ 0.
       CASE WA_TEMP_TABLE-FIELDNAME.
            WHEN 'NAME1'.
                 V_VAR = WA_KNA1-NAME1.
             WHEN 'PSTLZ'
                  V_VAR = WA_KNA1-PSTLZ.
    ENDIF.
    But using case is not appropriate as KNA1 contains 176 fields.

  • Adding new field from BKPF to tcode FB01 appearing as on selection screen

    Hi all,
    Could u please let us know to add a field from table BKPF in tcode FB01 ?
    1.   We did BADI for 'FI_HEADER_SUB_1300 ' and added the required field in the layout.
    2.   After actiavting, the added field is not getting reflected in the tcode FB01.
    Please tel us , where are we going wrong.

    Looks like a similar requirement in this: How to Add XREF1_HD(Reference Key 1 internal for document Header) field to header level to  transaction FB01

  • Urgent......  how to select few fields, from database table, (dynamic ita.)

    Dear all experts,
    I am able to populate all fields data from database table, using dynamic table creation.
    eg,
    SELECT *    FROM (w_tabname)    INTO    TABLE <t_itab>.
    where w_tabname is the table name given by the user, and t_itab is field symbol.
    but some requirement is like that i need to pick up only few fields, <b>which user will give at the runtime.</b>
    <b>I can</b> take those fields from file into any internal table,
    but the problem is that instead of <b>select *</b>, i need to put selected the fields given by user.
    i have tried with field symbol, it is not working (as per my knowledge.)
    do i need to create any structures dynamically ?
    Can anybody please help in this regards ?
    Your help will be surely rewarded with points.
    Waiting for reply..
    Regards
    Vinay

    Hi Vinay ,
    Adding to the below code , you can use some more fields in the select stmt as below:-
    REPORT ychatest.
    PARAMETERS : p_field1 LIKE dd03l-fieldname,
                             P_field2 LIKE dd03l-fieldname,
                             p_table LIKE dd03l-tabname.
    FIELD-SYMBOLS : <fs> TYPE STANDARD TABLE.
    SELECT (p_field1) (p_field2) ( FROM (p_table) INTO TABLE <fs>.
    Now p_field1 & p_field2  belong to the same table since you have give the user to enter only one table name.
    This should work fine.
    please try & let me know .
    Thanks & Regards,
    Daniel

Maybe you are looking for

  • Import Child Items In R12 with a template is not picking up from Interface

    Hi, When we are trying to Import Child Items of a master organization item, with a template name, records in the interface table are not picking up at all. We are doing this in R12, please let us know if any new columns become mandatory or what else

  • Airport Extreme with a B&W G3.  Can it be done?

    So we're upgrading our network, we currently have a G5 IMac and B&W and we just purchased an IBook with the Airport Extreme station and a card for the IMac. We're currently running with a Linksys Router which also has my Xbox connected to it. My ques

  • Norton claims today's Reader 11.0.4 update has a virus

    Has anyone determined whether today's security update to Reader 11.0.4 really does contain a virus in the ebook.api file as Norton claims? Norton's report is: Filename: ebook.api Threat name: Suspicious.Cloud.7.EP Full Path: c:\program files (x86)\ad

  • Modify the ASMA without defining the Sender and Receiver Interface

    Hi All, I am developing a scenario where I am picking files from NFS and putting in FTP. For this I am using only the ID and no IR content. So far so good. But Now we have a requirement to dynamically extract the target folder names from the File nam

  • Drag and Drop Restore Issue

    The hard drive on my first generation MacBook Air failed, and I had it replaced by Apple. They reinstalled all of the Apple software that was on my old drive. Now I'm trying to restore using a sparsebundle that I keep on an external drive. That part