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

small problem

Former Member
0 Likes
2,153

Hi to all,

according to my report...i have compared the <b>prices</b> of SALES and PURCHASES...

So every material have different sales orders...with different prices...

here problem is........purchase price comparing with all the sales orders....means repeating.....(only one purchase order for a particular material...but it is showing with all the sales orders..repeatedly)....finally in the result the total purchase netprice is wrong....

may be my select query is wrong...can u check once...

select VBAP~matnr

VBAK~VTWEG

VBAK~VKORG

VBAK~KUNNR

VBAK~AUART

VBAP~AUDAT

VBAP~NETPR

VBAP~ARKTX

VBAP~VRKME

VBAP~WAERK

VBAP~NETWR

VBAP~vbeln

VBAK~BSTNK

vbap~kwmeng

vbak~bstdk

VBAP~AUFNR

into corresponding fields of table mylist from VBAP

inner join VBAK

on VBAPVBELN = VBAKVBELN

where VBAK~kunnr in s_kunn1

and VBAP~AUDAT in s_AUDAT

and VBAP~MATNR in s_MATNR

and VBAK~AUART in s_AUART

and VBAK~VTWEG in s_VTWEG

and VBAP~AUFNR in s_AUFNR

and VBAK~VKORG in s_VKORG.

loop at mylist.

CLEAR: EINA, EIPA.

select single INFNR from eina into eina-infnr where MATNR =

mylist-matnr.

mylist-matnr1 = eina-matnr.

select single PREIS from eipa into eipa-preis where infnr = eina-infnr.

mylist-PREIS = eipa-preis.

select single EBELN from eipa into eipa-EBELN where infnr = eina-infnr.

mylist-EBELN = eipa-EBELN.

select single BEDAT from eipa into eipa-BEDAT where infnr = eina-infnr.

mylist-BEDAT = eipa-BEDAT.

mylist-PREDI = mylist-NETPR - mylist-PREIS.

modify mylist.

endloop.

raju.

22 REPLIES 22
Read only

Former Member
0 Likes
2,106

Hi Raju,

I have not thoroughly gone through your code but what i can immediately make out is that you have not cleared your internal table in loop. This might be a possible reason for values getting replicated.

Just add-

modify mylist.

****Added code *****

clear mylist.

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

endloop.

Read only

Former Member
0 Likes
2,106

Hi Raju,

Values are not repaeting in my opinion. Please add VBELN and POSNR to your table then you can recognise they are belongs to different documents.

Read only

Former Member
0 Likes
2,106

I don't think clearing is a problem....

as Murthy said , if you add vbeln posnr then you can see the difference...

though they are looking like duplicates but they are attached to different sales order,item...

please try to add vbeln,posnr to mylist and check ....

vijay

Read only

0 Likes
2,106

Hi,

i have added both vbeln and posnr....but no use..

otherwise give me an idea with using

EKPO-EBELN

EKPO-NETPR

and EKKO-EBELN

Message was edited by: mpr raju

Read only

0 Likes
2,106

You are getting multiple records still...

did you checked it with VBAK and VBAP tables.,...

vijay

Read only

0 Likes
2,106

Yes i have checked with VBAP and VBAK.

may be u got my point....NO problem with sales documents....but only with purchasing details...for ex..

material xxx is having sales orders 1000000123,1000000124,1000000125....etc....and

purchase order for material xxx is 200000123(555$price) and 200000124(666$ price)...

in the list it is taking only 555$ for all the documents....and only 200000123..

i think u got my point....

probelm with only purchasing details...

raju

Message was edited by: mpr raju

Read only

0 Likes
2,106

from vbfa you can link the ekko.

give vbtyp_V is V

vbtyp_N is C

you will get all the purchase order related to sales order and then goto ekko read the price..

vijay

hope you understand it...

Read only

0 Likes
2,106
select vbeln
       posnr
      from vbap
into table it_vbap.
      where vbeln in s_vbeln.
if sy-subrc = 0.
    SELECT  VBELV
            POSNV
            VBELN
            POSNN
            INTO TABLE IT_VBFA
            FROM VBFA
            FOR ALL ENTRIES IN IT_VBAP[]
            WHERE VBELV = IT_VBAP-VBELN
             AND  POSNV = IT_VBAP-POSNR
             AND  VBTYP_N = 'V'
             AND  VBTYP_V = 'C'.
 if sy-subrc = 0.
  select *
         from ekko
         into table it_ekko
         for all entries in it_vbfa[]
         where ebeln = it_vbfa-VBELN .
 endif.
endif.
Read only

0 Likes
2,106

hi thank u for the idea...hope this will work diffnetly..

its very good but one more doubt...

it is showing me the error

<b>The type of the database table and work area (or internal table)

"IT_EKKO" are not Unicode convertible. </b>

raju...

Read only

0 Likes
2,106

hi thank u for the idea...hope this will work diffnetly..

its very good but one more doubt...

it is showing me the error

<b>The type of the database table and work area (or internal table)

"IT_EKKO" are not Unicode convertible. </b>

raju...

Read only

0 Likes
2,106

just give me your code how you did, let me check...

and correct it.

Read only

0 Likes
2,106

I doubt there is some thing wrong in your declarations

it_ekko like ekko occurs 0 with header line.

but for testing i am using all fields, but select the fields which you are using only...

give the code , i will see and tell you...

Read only

0 Likes
2,106

HI THIS IS MY CODE ....ACCORDING TO UR IDEA...

type-pools: slis.

tables: VBAP, EKKO, VBFA.

data: length type i value 15.

data: txt_report like dokhl-object. "Reportname für Erläuterungsaufruf

data: begin of it_vbap occurs 0,

VBELN type vbap-vbeln,

POSNR type vbap-posnr,

MATNR type vbap-matnr,

AUDAT type vbap-audat,

NETPR type vbap-netpr,

ARKTX type vbap-arktx,

VRKME type vbap-vrkme,

WAERK type vbap-waerk,

NETWR type vbap-netwr,

KWMENG type vbap-kwmeng,

AUFNR type vbap-aufnr,

EBELN type VBAP-VBELN,

BEDAT type VBAP-AUDAT,

end of it_vbap.

data: begin of it_vbfa occurs 0,

VBELV type VBFA-VBELV,

POSNV type VBFA-POSNV,

VBELN type VBFA-VBELN,

POSNN type VBFA-POSNN,

end of it_vbfa.

data: begin of it_ekko occurs 0,

EBELN type EKKO-EBELN,

BEDAT type EKKO-BEDAT,

end of it_ekko.

DATA: EBELN LIKE EKKO-EBELN,

BEDAT LIKE EKKO-BEDAT.

data: gt_fieldcat type slis_t_fieldcat_alv,

gt_events type slis_t_event,

gd_repid like sy-repid,

gs_layout type slis_layout_alv.

form main.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = 'gd_repid'

  • 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 = gs_layout

it_fieldcat = gt_fieldcat[]

  • IT_EXCLUDING = ' '

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE =

  • IS_VARIANT =

it_events = gt_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

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab = it_vbap



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.

form data_retrival.

data: ld_color(1) type C.

select vbeln

posnr

matnr

posnr

netpr

netwr

from vbap

into table it_vbap

where vbeln in s_vbeln.

if sy-subrc = 0.

SELECT VBELV

POSNV

VBELN

POSNN

INTO TABLE IT_VBFA

FROM VBFA

FOR ALL ENTRIES IN IT_VBAP[]

WHERE VBELV = IT_VBAP-VBELN

AND POSNV = IT_VBAP-POSNR

AND VBTYP_N = 'V'

AND VBTYP_V = 'C'.

if sy-subrc = 0.

select ebeln from ekko into table it_ekko for all entries in it_vbfa[]

where ebeln = it_vbfa-VBELN.

endif.

endif.

endform.

Message was edited by: mpr raju

Message was edited by: mpr raju

Read only

0 Likes
2,106

Don't select from EKKO, after selecting from VBFA directly select from EKPO that will give price data

select ebeln
       posnr
       netpr
      from ekpo
      into table it_ekpo
      for all entries in it_VBFA[]
     where ebeln = it_VBFA-Vbeln
          and ebelp = it_vbfa-posnn.

<b>

salesorder->PO->Prices</b>

try this after selecting VBFA.

Message was edited by: Vijay Babu Dudla

Read only

0 Likes
2,106

Hi,

Look into the bold one and reward points if it is useful.

select vbeln

posnr

matnr

posnr

netpr

netwr

from vbap

into table it_vbap

where vbeln in s_vbeln.

if sy-subrc = 0.

SELECT VBELV

POSNV

VBELN

POSNN

INTO TABLE IT_VBFA

FROM VBFA

FOR ALL ENTRIES IN <b>IT_VBAP</b>

WHERE VBELV = IT_VBAP-VBELN

AND POSNV = IT_VBAP-POSNR

AND VBTYP_N = 'V'

AND VBTYP_V = 'C'.

if sy-subrc = 0.

select ebeln from ekko into table it_ekko for all entries in <b>it_vbfa</b>

where ebeln = it_vbfa-VBELN.

endif.

endif.

Read only

0 Likes
2,106

Hi Raju,

Can you please revert back if you have any questions..

vijay

Read only

0 Likes
2,106

Hi vijay....

im sorry to say u and also dont get angry....

still i didnt get...so...this is my code and please correct the entire code....where ever the mistake.....

for me it is executing but in debugging select query is not inserting the fields...

report two_line_test .

*line-size 90 no standard page heading.

*----


*

  • Programmversion; angelegt: 31.1.1995, Gerd Waloszek *

*----


*

  • Letzte Änderung: 25.2.98, Gerd Waloszek

  • Kopiert und umgestellt auf ALV: August 00, Andreas Groß *

*----


*

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

                                                  • Global data **********************************

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

*data: length type i value 18. " Length of list

type-pools: slis.

tables: VBAP, VBAK, VBFA, EKPO.

data: length type i value 15.

data: txt_report like dokhl-object. "Reportname für Erläuterungsaufruf

data: begin of it_vbap occurs 0,

  • VTWEG type vbak-vtweg,

  • VKORG type vbak-vkorg,

  • KUNNR type vbak-kunnr,

  • AUART type vbak-auart,

  • BSTDK type vbak-bstdk,

*

MATNR type vbap-matnr,

AUDAT type vbap-audat,

NETPR type vbap-netpr,

ARKTX type vbap-arktx,

VBELN type vbap-vbeln,

VRKME type vbap-vrkme,

WAERK type vbap-waerk,

NETWR type vbap-netwr,

KWMENG type vbap-kwmeng,

AUFNR type vbap-aufnr,

POSNR type vbap-posnr,

PREIS type vbap-netpr,

PREDI type VBAP-NETPR,

MATNR1 type vbap-MATNR,

INFNR type EIPA-INFNR,

  • BEDAT type EKPO-BEDAT,

EBELN type EKPO-ebeln,

NETPR1 type EKPO-NETPR,

end of it_vbap.

data: begin of it_vbfa occurs 0,

VBELV type vbfa-vbelv,

POSNV type vbfa-posnv,

VBELN type vbfa-vbeln,

POSNN type vbfa-posnn,

end of it_vbfa.

data: begin of it_ekpo occurs 0,

EBELN type ekpo-ebeln,

  • bedat type ekpo-bedat,

preis type ekpo-netpr,

  • posnr type ekpo-posnr,

end of it_ekpo.

DATA: PREIS LIKE ekpo-netpr ,

PREDI LIKE VBAP-NETPR,

EBELN like EIPA-EBELN,

NETPR1 LIKE EKPO-NETPR,

BEDAT like EIPA-BEDAT.

data: gt_fieldcat type slis_t_fieldcat_alv,

gt_events type slis_t_event,

gd_repid like sy-repid,

gs_layout type slis_layout_alv.

**********************SELECTION SCEREEN*******************************

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

******************************************BLOCK 2*********************

*SELECTION-SCREEN begin of block blk5 with frame title text-004.

********CHECK BOX******

*parameter: P_c2 as checkbox USER-COMMAND CHECK.

*data: cursorfield(20) type c.

*****************************************BLOCK 2 SUB******************

*

  • SELECTION-SCREEN begin of block 6 with frame title text-005.

*

SELECT-OPTIONS:

s_audat for VBAP-AUDAT no-extension, "Document Date.

s_vbeln for vbap-vbeln no-extension,

s_matnr for vbap-matnr no-extension.

  • SELECTION-SCREEN end of block 6.

*

*******************************************BLOCK 2

SUB******************

*

  • SELECTION-SCREEN begin of block 7 with frame title text-006.

*

SELECT-OPTIONS:

s_aufnr for vbap-aufnr no-extension no intervals.

  • SELECTION-SCREEN end of block 7.

*

*SELECTION-SCREEN end of block blk5.

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

                                                      • Main Program *******************************

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

perform data_retrival.

perform fieldcat_init using gt_fieldcat[].

perform layout_init using gs_layout.

perform eventtab_build using gt_events[].

perform main.

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

                                                      • Form Routines ******************************

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

*----


*

  • FORM MAIN *

*----


*

  • Main output routine *

*----


*

form main.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = 'gd_repid'

  • 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 = gs_layout

it_fieldcat = gt_fieldcat[]

  • IT_EXCLUDING = ' '

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE =

  • IS_VARIANT =

it_events = gt_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

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab = it_vbap

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.

*----


*

  • FORM FILL_ITAB *

*----


*

  • Fills the internal table for the list output *

*----


*

form data_retrival.

data: ld_color(1) type C.

select vbeln matnr posnr netpr netwr from vbap

into table it_vbap

where vbeln in s_vbeln.

if sy-subrc = 0.

SELECT VBELV POSNV VBELN POSNN INTO TABLE IT_VBFA FROM VBFA

FOR ALL ENTRIES IN IT_VBAP

WHERE VBELV = IT_VBAP-VBELN

AND POSNV = IT_VBAP-POSNR

AND VBTYP_N = 'V'

AND VBTYP_V = 'C'.

if sy-subrc = 0.

select ebeln netpr from ekpo into table it_ekpo for all entries

in it_vbfa where ebeln = it_vbfa-VBELN.

endif.

endif.

endform.

*----


*

  • Programmversion; angelegt: 14.2.1995, Gerd Waloszek *

*----


*

  • Letzte Änderung: 26.2.98, Gerd Waloszek *

*----


*

data: fix_cols type i, " Variables for horizontal

fix_line. " scrolling

*----


*

  • FORM FIELDCAT_INIT

*

*----


*

form fieldcat_init using lt_fieldcat type slis_t_fieldcat_alv.

data: ls_fieldcat type slis_fieldcat_alv.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'VBELN'.

  • ls_fieldcat-datatype = 'C'.

ls_fieldcat-outputlen = '15'.

  • ls_fieldcat-key = 'X'.

ls_fieldcat-emphasize = 'C511'.

ls_fieldcat-seltext_l = text-z10.

ls_fieldcat-seltext_m = text-z10.

ls_fieldcat-seltext_s = text-z10.

ls_fieldcat-reptext_ddic = text-z10.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'POSNR'.

  • ls_fieldcat-datatype = 'C'.

ls_fieldcat-outputlen = '10'.

  • ls_fieldcat-key = 'X'.

  • ls_fieldcat-emphasize = 'C511'.

ls_fieldcat-seltext_l = text-z11.

ls_fieldcat-seltext_m = text-z11.

ls_fieldcat-seltext_s = text-z11.

ls_fieldcat-reptext_ddic = text-z11.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'AUDAT'.

  • ls_fieldcat-datatype = 'C'.

ls_fieldcat-outputlen = '20'.

  • ls_fieldcat-key = 'X'.

  • ls_fieldcat-emphasize = 'C511'.

ls_fieldcat-seltext_l = text-z11.

ls_fieldcat-seltext_m = text-z11.

ls_fieldcat-seltext_s = text-z11.

ls_fieldcat-reptext_ddic = text-z11.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'KUNNR'.

  • ls_fieldcat-datatype = 'C'.

  • ls_fieldcat-row_pos = '2'.

  • ls_fieldcat-key = 'X'.

ls_fieldcat-outputlen = '10'.

  • ls_fieldcat-emphasize = 'C500'.

ls_fieldcat-seltext_l = text-z30.

ls_fieldcat-seltext_m = text-z30.

ls_fieldcat-seltext_s = text-z30.

ls_fieldcat-reptext_ddic = text-z30.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'AUFNR'.

  • ls_fieldcat-datatype = 'C'.

  • ls_fieldcat-row_pos = '2'.

  • ls_fieldcat-key = 'X'.

ls_fieldcat-outputlen = '07'.

  • ls_fieldcat-emphasize = 'C500'.

ls_fieldcat-seltext_l = text-z31.

ls_fieldcat-seltext_m = text-z31.

ls_fieldcat-seltext_s = text-z31.

ls_fieldcat-reptext_ddic = text-z31.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'NETPR'.

  • ls_fieldcat-datatype = 'DATS'.

ls_fieldcat-outputlen = '14'.

  • ls_fieldcat-emphasize = 'C501'.

ls_fieldcat-do_sum = 'X'.

ls_fieldcat-seltext_l = text-z40.

  • ls_fieldcat-row_pos = '2'.

ls_fieldcat-seltext_m = text-z40.

ls_fieldcat-seltext_s = text-z40.

ls_fieldcat-reptext_ddic = text-z40.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'NETWR'.

  • ls_fieldcat-datatype = 'DATS'.

ls_fieldcat-outputlen = '26'.

  • ls_fieldcat-emphasize = 'C200'.

ls_fieldcat-do_sum = 'X'.

ls_fieldcat-seltext_l = text-z90.

  • ls_fieldcat-row_pos = '2'.

ls_fieldcat-seltext_m = text-z90.

ls_fieldcat-seltext_s = text-z90.

ls_fieldcat-reptext_ddic = text-z90.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'KWMENG'.

  • ls_fieldcat-datatype = 'DATS'.

ls_fieldcat-outputlen = '06'.

  • ls_fieldcat-emphasize = 'C200'.

ls_fieldcat-seltext_l = text-z91.

  • ls_fieldcat-row_pos = '2'.

ls_fieldcat-seltext_m = text-z91.

ls_fieldcat-seltext_s = text-z91.

ls_fieldcat-reptext_ddic = text-z91.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'AUART'.

  • ls_fieldcat-datatype = 'DATS'.

ls_fieldcat-outputlen = '06'.

  • ls_fieldcat-emphasize = 'C200'.

ls_fieldcat-seltext_l = text-z60.

  • ls_fieldcat-row_pos = '2'.

ls_fieldcat-seltext_m = text-z60.

ls_fieldcat-seltext_s = text-z60.

ls_fieldcat-reptext_ddic = text-z60.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'ARKTX'.

  • ls_fieldcat-datatype = 'DATS'.

ls_fieldcat-outputlen = '15'.

  • ls_fieldcat-emphasize = 'C200'.

ls_fieldcat-seltext_l = text-z70.

  • ls_fieldcat-row_pos = '2'.

ls_fieldcat-seltext_m = text-z70.

ls_fieldcat-seltext_s = text-z70.

ls_fieldcat-reptext_ddic = text-z70.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'VRKME'.

  • ls_fieldcat-datatype = 'DATS'.

ls_fieldcat-outputlen = '04'.

  • ls_fieldcat-emphasize = 'C200'.

ls_fieldcat-seltext_l = text-z80.

  • ls_fieldcat-row_pos = '2'.

ls_fieldcat-seltext_m = text-z80.

ls_fieldcat-seltext_s = text-z80.

ls_fieldcat-reptext_ddic = text-z80.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'VKORG'.

  • ls_fieldcat-datatype = 'DATS'.

ls_fieldcat-outputlen = '05'.

  • ls_fieldcat-emphasize = 'C400'.

ls_fieldcat-seltext_l = text-z50.

  • ls_fieldcat-row_pos = '2'.

ls_fieldcat-seltext_m = text-z50.

ls_fieldcat-seltext_s = text-z50.

ls_fieldcat-reptext_ddic = text-z50.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'EBELN'.

  • ls_fieldcat-datatype = 'DATS'.

ls_fieldcat-outputlen = '15'.

ls_fieldcat-emphasize = 'C711'.

ls_fieldcat-seltext_l = text-z92.

ls_fieldcat-row_pos = '2'.

ls_fieldcat-seltext_m = text-z92.

ls_fieldcat-seltext_s = text-z92.

ls_fieldcat-reptext_ddic = text-z92.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'BEDAT'.

  • ls_fieldcat-datatype = 'DATS'.

ls_fieldcat-outputlen = '12'.

  • ls_fieldcat-emphasize = 'C200'.

ls_fieldcat-seltext_l = text-z93.

ls_fieldcat-row_pos = '2'.

ls_fieldcat-seltext_m = text-z93.

ls_fieldcat-seltext_s = text-z93.

ls_fieldcat-reptext_ddic = text-z93.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'MATNR'.

  • ls_fieldcat-datatype = 'C'.

  • ls_fieldcat-key = 'X'.

ls_fieldcat-outputlen = '17'.

ls_fieldcat-row_pos = '2'.

ls_fieldcat-seltext_l = text-z20.

  • ls_fieldcat-emphasize = 'C500'.

ls_fieldcat-seltext_m = text-z20.

ls_fieldcat-seltext_s = text-z20.

ls_fieldcat-reptext_ddic = text-z20.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'NETPR'.

  • ls_fieldcat-datatype = 'DATS'.

ls_fieldcat-outputlen = '23'.

  • ls_fieldcat-emphasize = 'C701'.

ls_fieldcat-seltext_l = text-z94.

ls_fieldcat-row_pos = '2'.

ls_fieldcat-do_sum = 'X'.

ls_fieldcat-seltext_m = text-z94.

ls_fieldcat-seltext_s = text-z94.

ls_fieldcat-reptext_ddic = text-z94.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'PREDI'.

  • ls_fieldcat-datatype = 'DATS'.

ls_fieldcat-outputlen = '11'.

  • ls_fieldcat-emphasize = 'C200'.

ls_fieldcat-seltext_l = text-z95.

ls_fieldcat-do_sum = 'X'.

ls_fieldcat-row_pos = '2'.

ls_fieldcat-seltext_m = text-z95.

ls_fieldcat-seltext_s = text-z95.

ls_fieldcat-reptext_ddic = text-z95.

append ls_fieldcat to lt_fieldcat.

endform.

form layout_init using ls_layout type slis_layout_alv.

ls_layout-zebra = 'X'.

endform.

*----


*

  • FORM EVENTTAB_BUILD *

*----


*

  • ........ *

*----


*

  • --> LT_EVENTS *

*----


*

form eventtab_build using lt_events type slis_t_event.

data: ls_event type slis_alv_event.

move 'PF_STATUS_SET' to ls_event-name.

move 'SEMI_TOOLBAR' to ls_event-form.

append ls_event to lt_events.

clear ls_event.

move 'USER_COMMAND' to ls_event-name.

move 'USER_COMMAND' to ls_event-form.

append ls_event to lt_events.

clear ls_event.

endform.

*----

-


  • FORM PF_STATUS_SET

*----

-


form semi_toolbar using extab type slis_t_extab. "#EC CALLED

set pf-status 'SEMI_TOOLBAR' excluding extab.

endform.

*----


*

  • FORM user_command *

*----


*

  • ........ *

*----


*

  • --> RF_UCOMM *

  • --> RS_SELFIELD *

*----


*

form user_command using rf_ucomm like sy-ucomm

rs_selfield type slis_selfield. "#EC CALLED

case rf_ucomm.

when 'ERLE'.

txt_report = 'ZTWO_LINE_TEST'.

call function 'ERGO_TEXT_SHOW'

exporting

textname = txt_report

id = 'RE'

langu = sy-langu.

endcase.

endform.

Message was edited by: mpr raju

Read only

0 Likes
2,106
report two_line_test .

type-pools: slis.

tables: VBAP, VBAK, VBFA, EKPO.
data: length type i value 15.

data: txt_report like dokhl-object. "Reportname für Erläuterungsaufruf

data: begin of it_vbap occurs 0,
vbeln type vbap-vbeln,
posnr like vbap-posnr,
MATNR type vbap-matnr,
*AUDAT type vbak-audat,
NETPR type vbap-netpr,
ARKTX type vbap-arktx,
VRKME type vbap-vrkme,
WAERK type vbap-waerk,
NETWR type vbap-netwr,
KWMENG type vbap-kwmeng,
AUFNR type vbap-aufnr,
PREIS type vbap-netpr,
PREDI type VBAP-NETPR,
MATNR1 type vbap-MATNR,
INFNR type EIPA-INFNR,
EBELN type EKPO-ebeln,
NETPR1 type EKPO-NETPR,
end of it_vbap.

data: begin of it_vbfa occurs 0,
VBELV type vbfa-vbelv,
POSNV type vbfa-posnv,
VBELN type vbfa-vbeln,
POSNN type vbfa-posnn,
end of it_vbfa.


data: begin of it_ekpo occurs 0,
EBELN type ekpo-ebeln,
ebelp type ekpo-ebelp,
preis type ekpo-netpr,
end of it_ekpo.

DATA: PREIS LIKE ekpo-netpr ,
PREDI LIKE VBAP-NETPR,
EBELN like EIPA-EBELN,
NETPR1 LIKE EKPO-NETPR,
BEDAT like EIPA-BEDAT.



data: gt_fieldcat type slis_t_fieldcat_alv,
gt_events type slis_t_event,
gd_repid like sy-repid,
gs_layout type slis_layout_alv.

***********************SELECTION SCEREEN********************************

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

*******************************************BLOCK 2**********************

*SELECTION-SCREEN begin of block blk5 with frame title text-004.

*********CHECK BOX*******

*parameter: P_c2 as checkbox USER-COMMAND CHECK.

*data: cursorfield(20) type c.

******************************************BLOCK 2 SUB*******************
*
* SELECTION-SCREEN begin of block 6 with frame title text-005.
*
SELECT-OPTIONS:
s_audat for VBAk-AUDAT no-extension, "Document Date.
s_kunn1 for vbak-kunnr no-extension,
s_vbeln for vbap-vbeln no-extension,
s_matnr for vbap-matnr no-extension.

* SELECTION-SCREEN end of block 6.
*
*******************************************BLOCK 2
*SUB*******************
*
* SELECTION-SCREEN begin of block 7 with frame title text-006.
*
SELECT-OPTIONS:

s_auart for vbak-auart no-extension no intervals,
s_vtweg for vbak-vtweg no-extension no intervals,
s_aufnr for vbap-aufnr no-extension no intervals,
s_vkorg for vbak-vkorg no-extension no intervals.

* SELECTION-SCREEN end of block 7.
*
*SELECTION-SCREEN end of block blk5.


************************************************************************
*************************** Main Program *******************************
************************************************************************

perform data_retrival.
perform fieldcat_init using gt_fieldcat[].
perform layout_init using gs_layout.
perform eventtab_build using gt_events[].
perform main.

************************************************************************
*************************** Form Routines ******************************
************************************************************************

*---------------------------------------------------------------------*
* FORM MAIN *
*---------------------------------------------------------------------*
* Main output routine *
*---------------------------------------------------------------------*
form main.

call function 'REUSE_ALV_LIST_DISPLAY'
exporting
* I_INTERFACE_CHECK = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = 'gd_repid'
* 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 = gs_layout
it_fieldcat = gt_fieldcat[]
* IT_EXCLUDING = ' '
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE =
* IS_VARIANT =
it_events = gt_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
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = it_vbap
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.

*---------------------------------------------------------------------*
* FORM FILL_ITAB *
*---------------------------------------------------------------------*
* Fills the internal table for the list output *
*---------------------------------------------------------------------*
form data_retrival.

data: ld_color(1) type C.

select * from vbap
into corresponding fields of table it_vbap
where vbeln in s_vbeln.
if sy-subrc = 0.

SELECT VBELV POSNV VBELN POSNN INTO TABLE IT_VBFA FROM VBFA
FOR ALL ENTRIES IN IT_VBAP
WHERE VBELV = IT_VBAP-VBELN
AND POSNV = IT_VBAP-POSNR
AND VBTYP_N = 'V'
AND VBTYP_V = 'C'.
if sy-subrc = 0.

select ebeln ebelp netpr from ekpo into table it_ekpo for all entries
in it_vbfa[]
 where ebeln = it_vbfa-VBELN.

endif.
endif.
data: l_index type sy-tabix.
loop at it_vbap.
l_index = sy-tabix.
read table it_vbfa with key vbelv = it_vbap-vbeln
                            posnv = it_vbap-posnr.

 if sy-subrc = 0.
 read table it_ekpo with key ebeln = it_vbfa-vbeln
                             ebelp = it_vbfa-posnn.

    if sy-subrc = 0.
    it_vbap-EBELN = it_ekpo-ebeln.
 it_vbap-NETPR1 = it_EKPO-preis.
 modify it_vbap index l_index.
    endif.
 endif.
endloop.
endform.

*----------------------------------------------------------------------*
* Programmversion; angelegt: 14.2.1995, Gerd Waloszek *
*----------------------------------------------------------------------*
* Letzte Änderung: 26.2.98, Gerd Waloszek *
*----------------------------------------------------------------------*

data: fix_cols type i, " Variables for horizontal
fix_line. " scrolling

*---------------------------------------------------------------------*
* FORM FIELDCAT_INIT
*
*---------------------------------------------------------------------*

form fieldcat_init using lt_fieldcat type slis_t_fieldcat_alv.
data: ls_fieldcat type slis_fieldcat_alv.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'VBELN'.
* ls_fieldcat-datatype = 'C'.
ls_fieldcat-outputlen = '15'.
* ls_fieldcat-key = 'X'.
ls_fieldcat-emphasize = 'C511'.
ls_fieldcat-seltext_l = text-z10.
ls_fieldcat-seltext_m = text-z10.
ls_fieldcat-seltext_s = text-z10.
ls_fieldcat-reptext_ddic = text-z10.


append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'POSNR'.
* ls_fieldcat-datatype = 'C'.
ls_fieldcat-outputlen = '10'.
* ls_fieldcat-key = 'X'.
* ls_fieldcat-emphasize = 'C511'.
ls_fieldcat-seltext_l = text-z11.
ls_fieldcat-seltext_m = text-z11.
ls_fieldcat-seltext_s = text-z11.
ls_fieldcat-reptext_ddic = text-z11.


append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'AUDAT'.
* ls_fieldcat-datatype = 'C'.
ls_fieldcat-outputlen = '20'.
* ls_fieldcat-key = 'X'.
* ls_fieldcat-emphasize = 'C511'.
ls_fieldcat-seltext_l = text-z11.
ls_fieldcat-seltext_m = text-z11.
ls_fieldcat-seltext_s = text-z11.
ls_fieldcat-reptext_ddic = text-z11.


append ls_fieldcat to lt_fieldcat.


clear ls_fieldcat.

ls_fieldcat-fieldname = 'KUNNR'.
* ls_fieldcat-datatype = 'C'.
* ls_fieldcat-row_pos = '2'.
* ls_fieldcat-key = 'X'.
ls_fieldcat-outputlen = '10'.
* ls_fieldcat-emphasize = 'C500'.
ls_fieldcat-seltext_l = text-z30.
ls_fieldcat-seltext_m = text-z30.
ls_fieldcat-seltext_s = text-z30.
ls_fieldcat-reptext_ddic = text-z30.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'AUFNR'.
* ls_fieldcat-datatype = 'C'.
* ls_fieldcat-row_pos = '2'.
* ls_fieldcat-key = 'X'.
ls_fieldcat-outputlen = '07'.
* ls_fieldcat-emphasize = 'C500'.
ls_fieldcat-seltext_l = text-z31.
ls_fieldcat-seltext_m = text-z31.
ls_fieldcat-seltext_s = text-z31.
ls_fieldcat-reptext_ddic = text-z31.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'NETPR'.
* ls_fieldcat-datatype = 'DATS'.
ls_fieldcat-outputlen = '14'.
* ls_fieldcat-emphasize = 'C501'.
ls_fieldcat-do_sum = 'X'.
ls_fieldcat-seltext_l = text-z40.
* ls_fieldcat-row_pos = '2'.
ls_fieldcat-seltext_m = text-z40.
ls_fieldcat-seltext_s = text-z40.
ls_fieldcat-reptext_ddic = text-z40.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'NETWR'.
* ls_fieldcat-datatype = 'DATS'.
ls_fieldcat-outputlen = '26'.
* ls_fieldcat-emphasize = 'C200'.
ls_fieldcat-do_sum = 'X'.
ls_fieldcat-seltext_l = text-z90.
* ls_fieldcat-row_pos = '2'.
ls_fieldcat-seltext_m = text-z90.
ls_fieldcat-seltext_s = text-z90.
ls_fieldcat-reptext_ddic = text-z90.

append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.

ls_fieldcat-fieldname = 'KWMENG'.
* ls_fieldcat-datatype = 'DATS'.
ls_fieldcat-outputlen = '06'.
* ls_fieldcat-emphasize = 'C200'.
ls_fieldcat-seltext_l = text-z91.
* ls_fieldcat-row_pos = '2'.
ls_fieldcat-seltext_m = text-z91.
ls_fieldcat-seltext_s = text-z91.
ls_fieldcat-reptext_ddic = text-z91.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'AUART'.
* ls_fieldcat-datatype = 'DATS'.
ls_fieldcat-outputlen = '06'.
* ls_fieldcat-emphasize = 'C200'.
ls_fieldcat-seltext_l = text-z60.
* ls_fieldcat-row_pos = '2'.
ls_fieldcat-seltext_m = text-z60.
ls_fieldcat-seltext_s = text-z60.
ls_fieldcat-reptext_ddic = text-z60.

append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.

ls_fieldcat-fieldname = 'ARKTX'.
* ls_fieldcat-datatype = 'DATS'.
ls_fieldcat-outputlen = '15'.
* ls_fieldcat-emphasize = 'C200'.
ls_fieldcat-seltext_l = text-z70.
* ls_fieldcat-row_pos = '2'.
ls_fieldcat-seltext_m = text-z70.
ls_fieldcat-seltext_s = text-z70.
ls_fieldcat-reptext_ddic = text-z70.

append ls_fieldcat to lt_fieldcat.
clear ls_fieldcat.

ls_fieldcat-fieldname = 'VRKME'.
* ls_fieldcat-datatype = 'DATS'.
ls_fieldcat-outputlen = '04'.
* ls_fieldcat-emphasize = 'C200'.
ls_fieldcat-seltext_l = text-z80.
* ls_fieldcat-row_pos = '2'.
ls_fieldcat-seltext_m = text-z80.
ls_fieldcat-seltext_s = text-z80.
ls_fieldcat-reptext_ddic = text-z80.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'VKORG'.
* ls_fieldcat-datatype = 'DATS'.
ls_fieldcat-outputlen = '05'.
* ls_fieldcat-emphasize = 'C400'.
ls_fieldcat-seltext_l = text-z50.
* ls_fieldcat-row_pos = '2'.
ls_fieldcat-seltext_m = text-z50.
ls_fieldcat-seltext_s = text-z50.
ls_fieldcat-reptext_ddic = text-z50.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'EBELN'.
* ls_fieldcat-datatype = 'DATS'.
ls_fieldcat-outputlen = '15'.
ls_fieldcat-emphasize = 'C711'.
ls_fieldcat-seltext_l = text-z92.
ls_fieldcat-row_pos = '2'.
ls_fieldcat-seltext_m = text-z92.
ls_fieldcat-seltext_s = text-z92.
ls_fieldcat-reptext_ddic = text-z92.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'BEDAT'.
* ls_fieldcat-datatype = 'DATS'.
ls_fieldcat-outputlen = '12'.
* ls_fieldcat-emphasize = 'C200'.
ls_fieldcat-seltext_l = text-z93.
ls_fieldcat-row_pos = '2'.
ls_fieldcat-seltext_m = text-z93.
ls_fieldcat-seltext_s = text-z93.
ls_fieldcat-reptext_ddic = text-z93.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'MATNR'.
* ls_fieldcat-datatype = 'C'.
* ls_fieldcat-key = 'X'.
ls_fieldcat-outputlen = '17'.
ls_fieldcat-row_pos = '2'.
ls_fieldcat-seltext_l = text-z20.
* ls_fieldcat-emphasize = 'C500'.
ls_fieldcat-seltext_m = text-z20.
ls_fieldcat-seltext_s = text-z20.
ls_fieldcat-reptext_ddic = text-z20.


append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'NETPR'.
* ls_fieldcat-datatype = 'DATS'.
ls_fieldcat-outputlen = '23'.
* ls_fieldcat-emphasize = 'C701'.
ls_fieldcat-seltext_l = text-z94.
ls_fieldcat-row_pos = '2'.
ls_fieldcat-do_sum = 'X'.
ls_fieldcat-seltext_m = text-z94.
ls_fieldcat-seltext_s = text-z94.
ls_fieldcat-reptext_ddic = text-z94.

append ls_fieldcat to lt_fieldcat.

clear ls_fieldcat.

ls_fieldcat-fieldname = 'PREDI'.
* ls_fieldcat-datatype = 'DATS'.
ls_fieldcat-outputlen = '11'.
* ls_fieldcat-emphasize = 'C200'.
ls_fieldcat-seltext_l = text-z95.
ls_fieldcat-do_sum = 'X'.
ls_fieldcat-row_pos = '2'.
ls_fieldcat-seltext_m = text-z95.
ls_fieldcat-seltext_s = text-z95.
ls_fieldcat-reptext_ddic = text-z95.

append ls_fieldcat to lt_fieldcat.


endform.

form layout_init using ls_layout type slis_layout_alv.

ls_layout-zebra = 'X'.

endform.


*---------------------------------------------------------------------*
* FORM EVENTTAB_BUILD *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> LT_EVENTS *
*---------------------------------------------------------------------*
form eventtab_build using lt_events type slis_t_event.

data: ls_event type slis_alv_event.

move 'PF_STATUS_SET' to ls_event-name.
move 'SEMI_TOOLBAR' to ls_event-form.
append ls_event to lt_events.
clear ls_event.

move 'USER_COMMAND' to ls_event-name.
move 'USER_COMMAND' to ls_event-form.
append ls_event to lt_events.
clear ls_event.


endform.

*-----------------------------------------------------------------------
* FORM PF_STATUS_SET
*-----------------------------------------------------------------------
form semi_toolbar using extab type slis_t_extab. "#EC CALLED
set pf-status 'SEMI_TOOLBAR' excluding extab.
endform.



*---------------------------------------------------------------------*
* FORM user_command *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> RF_UCOMM *
* --> RS_SELFIELD *
*---------------------------------------------------------------------*
form user_command using rf_ucomm like sy-ucomm
rs_selfield type slis_selfield. "#EC CALLED

case rf_ucomm.

when 'ERLE'.
txt_report = 'ZTWO_LINE_TEST'.
call function 'ERGO_TEXT_SHOW'
exporting
textname = txt_report
id = 'RE'
langu = sy-langu.


endcase.
endform.

Read only

0 Likes
2,106

Hi vijay...may be ur checked it or not ....but the purchase details are not displaying....

raju

Message was edited by: mpr raju

Read only

0 Likes
2,106

I will check it and let you know...

regards

vijay

Read only

0 Likes
2,106

Hi Raju,

Check the data actually there are sales orders with out Purchasing data, try to find the test data and see the details...

vijay

Read only

0 Likes
2,106

if you really think some problem in code, just take the sales orders and go to VBFA table and find the PO's

if it fails then there is no PO data .

try to find some test data.

regards

vijay