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

alv

Former Member
0 Likes
526

HI THIS IS THE LOGIC........need to create prog in ALV .

Need help.

Pre-requisite

Document Number should exist in the database.

Program Logic/Pseudo Code:

Logic would be as under:

1. A new screen is to be prepared. Input would be the followings:

a. Company code

b. Posting Date (From – To)

2. Select all BELNR (Accounting Document Numbers) from table BSAK where BLART is either KR or RE.

3. For all selected BELNR get only those BELNR which are available in the table BSIS where HKONT is 27611002.

4. For these BELNR get all the line items from the table BSIS where BSCHL is equal to 40. Get the report in the following format.

5. All the above mentioned searches to be made for company code 1000.

Report Layout (For Reports):-----

BSIS-BLDAT, BSIS-BUDAT, BSIS-BELNR, BSIS-HKONT, BSIS-WRBTR, BSAK-AUGDT, BSAK-LIFNR, BSAK-AUGBL

THANKS.

4 REPLIES 4
Read only

Former Member
0 Likes
495

Hi Sam ,

What is the help you want , if you can be specific it would help us answer the question better.

Looking at your requirement , it does not seem to tough , i have just one query regaridng the specification given , your program takes as input company code , but at step 5 it is given 'All the above mentioned searches to be made for company code 1000' .

So what is the use of having the company code as input.

Please revert back , with your queries.

Regards

Arun

Read only

Former Member
0 Likes
495

hi sam,

u want the code or what kind of help ? pls be littile more specific so that i can try my best.

with regards,

S.Barane

Read only

Former Member
0 Likes
495

Hi sam,

you want this to be in alv grid ?

i have already posted the code for the same in previuos thread,but in report.

in alv your internal table declaration will be same select query will be same the only difference will be you have to call some function modules like

<b>reuse_alv_fieldcatalog_merge ; and

reuse_alv_grid_display.</b>

REPORT  YTESTPS2.

tables: bsak,bsis.
type-pools slis.
 
data: begin of itab occurs 0,
      bukrs like bsak-bukrs,
      augbl like bsak-augbl,
      augdt like bsak-augdt,
      hkont like bsak-hkont,
      zuonr like bsak-zuonr,
      gjahr like bsak-gjahr,
      lifnr like bsak-lifnr,
      bldat like bsis-bldat,
      belnr like bsis-belnr,
      wrbtr like bsis-wrbtr,
      budat like bsak-budat,
      end of itab.
 
data i_fcat type slis_t_fieldcat_alv.
 
selection-screen begin of block b with frame title text-001. " give the text in that
selection-screen begin of line.
selection-screen comment 1(15) text-002." give text as company code
parameters x like bsak-bukrs.
selection-screen end of line.
 
selection-screen begin of line.
selection-screen comment 1(15) text-003. " give text as date
select-options y for bsak-budat.
selection-screen end of line.
selection-screen end of block b.
 
*to give text double click on text-001...like that..save and activate
 
start-of-selection.
 
select k~augdt k~lifnr k~augbl s~bldat s~budat s~belnr s~hkont s~wrbtr
into corresponding fields of table itab
from bsak as k inner join bsis as s on k~bukrs = s~bukrs AND
k~augbl = s~augbl AND
k~augdt = s~augdt AND
k~hkont = s~hkont AND
k~zuonr = s~zuonr AND
k~gjahr = s~gjahr
where k~bukrs = x and s~budat in y and k~bukrs = '1000' and s~hkont = '27611002' and s~bschl = '40'.
 
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
 EXPORTING
   I_PROGRAM_NAME               = 'ytestps2'  " your program name
   I_INTERNAL_TABNAME           = itab
*   I_STRUCTURE_NAME             =
*   I_CLIENT_NEVER_DISPLAY       = 'X'
*   I_INCLNAME                   =
*   I_BYPASSING_BUFFER           =
*   I_BUFFER_ACTIVE              =
  CHANGING
    CT_FIELDCAT                  = i_fcat
* EXCEPTIONS
*   INCONSISTENT_INTERFACE       = 1
*   PROGRAM_ERROR                = 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.



CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
 EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
   I_CALLBACK_PROGRAM                = 'ytestps2'
*   I_CALLBACK_PF_STATUS_SET          = ' '
*   I_CALLBACK_USER_COMMAND           = ' '
*   I_CALLBACK_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                       = i_fcat
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
   I_SAVE                            = 'A'
*   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                          = itab
* 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.

this is a simple grid display.. i have just givenm you the idea as how you have to carry out your program.

regards,

pankaj singh

Read only

Former Member
0 Likes
495

Hi,

Use this logic just change the field names and select statement according to your requirement.

&----


*& Report ZDEMO_ALVGRID *

*& *

&----


*& *

*& Example of a simple ALV Grid Report with grand total *

*& ................................... *

*& *

*& The basic requirement for this demo is to display a number of *

*& fields from the EKKO table. *

&----


REPORT zdemo_alvgrid .

TABLES: ekko.

type-pools: slis. "ALV Declarations

*Data Declaration

*----


TYPES: BEGIN OF t_ekko,

ebeln TYPE ekpo-ebeln,

ebelp TYPE ekpo-ebelp,

statu TYPE ekpo-statu,

aedat TYPE ekpo-aedat,

matnr TYPE ekpo-matnr,

menge TYPE ekpo-menge,

meins TYPE ekpo-meins,

netpr TYPE ekpo-netpr,

peinh TYPE ekpo-peinh,

END OF t_ekko.

DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,

wa_ekko TYPE t_ekko.

*ALV data declarations

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,

gd_repid like sy-repid.

************************************************************************

*Start-of-selection.

START-OF-SELECTION.

perform data_retrieval.

perform build_fieldcatalog.

perform build_layout.

perform display_alv_report.

&----


*& Form BUILD_FIELDCATALOG

&----


  • Build Fieldcatalog for ALV Report

----


form build_fieldcatalog.

fieldcatalog-fieldname = 'EBELN'.

fieldcatalog-seltext_m = 'Purchase Order'.

fieldcatalog-col_pos = 0.

fieldcatalog-outputlen = 10.

fieldcatalog-emphasize = 'X'.

fieldcatalog-key = 'X'.

  • fieldcatalog-do_sum = 'X'.

  • fieldcatalog-no_zero = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'EBELP'.

fieldcatalog-seltext_m = 'PO Item'.

fieldcatalog-col_pos = 1.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'STATU'.

fieldcatalog-seltext_m = 'Status'.

fieldcatalog-col_pos = 2.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'AEDAT'.

fieldcatalog-seltext_m = 'Item change date'.

fieldcatalog-col_pos = 3.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'Material Number'.

fieldcatalog-col_pos = 4.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MENGE'.

fieldcatalog-seltext_m = 'PO quantity'.

fieldcatalog-col_pos = 5.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MEINS'.

fieldcatalog-seltext_m = 'Order Unit'.

fieldcatalog-col_pos = 6.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'NETPR'.

fieldcatalog-seltext_m = 'Net Price'.

fieldcatalog-col_pos = 7.

fieldcatalog-outputlen = 15.

fieldcatalog-do_sum = 'X'. "Display column total

fieldcatalog-datatype = 'CURR'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'PEINH'.

fieldcatalog-seltext_m = 'Price Unit'.

fieldcatalog-col_pos = 8.

  • to make editable field

  • fieldcatalog-edit = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

endform. " BUILD_FIELDCATALOG

&----


*& Form BUILD_LAYOUT

&----


  • Build layout for ALV grid report

----


form build_layout.

gd_layout-no_input = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-totals_text = 'Totals'(201).

endform. " BUILD_LAYOUT

&----


*& Form DISPLAY_ALV_REPORT

&----


  • Display report using ALV grid

----


form display_alv_report.

gd_repid = sy-repid.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = gd_repid

is_layout = gd_layout

it_fieldcat = fieldcatalog[]

i_save = 'X'

tables

t_outtab = it_ekko

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 DATA_RETRIEVAL

&----


  • Retrieve data form EKPO table and populate itab it_ekko

----


form data_retrieval.

select ebeln ebelp statu aedat matnr menge meins netpr peinh

up to 10 rows

from ekpo

into table it_ekko.

endform. " DATA_RETRIEVAL

Regards,

Rajneesh Gupta