Application Development 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: 

How to use RV_KONV_SELECT function and get fields

Former Member
0 Kudos

Hi I'm new in the SAP world and I meet a problem in an exercise. I would like to get 3 fields in the KONV table with the RV_KONV_SELECT function : cnty in kschl field, amount in kbetr field and crcy in waers field. But I can't do it because I don't know how to use it. This is my current code :

SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S31 { font-style: italic; color: #808080; } .L0S32 { color: #3399FF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; }

*&---------------------------------------------------------------------*
*& Report Z_TEST_ORDER
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT z_test_order.

TABLES : vbak.

*---------------------------------------------------------------------*
* Global selection screen
*---------------------------------------------------------------------*

SELECTION-SCREEN BEGIN OF SCREEN 100.
SELECT-OPTIONS :
s_vbeln FOR vbak-vbeln.
SELECTION-SCREEN END OF SCREEN 100.

*---------------------------------------------------------------------*
* Declarations
*---------------------------------------------------------------------*

CLASS cmd DEFINITION.
PUBLIC SECTION.
METHODS : getkonv,
getcmdresult,
getnbcmdresult,
printnbcmdresult,
printcmdresult.

CLASS-METHODS : main.

PRIVATE SECTION.
TYPES : BEGIN OF type,
vbeln TYPE vbak-vbeln,
auart TYPE vbak-auart,
name1 TYPE kna1-name1,
name1bis TYPE lfa1-name1,

posnr TYPE vbap-posnr,
matnr TYPE rv45a-matnr,
kwmeng TYPE rv45a-kwmeng,
vrkme TYPE vbap-vrkme,
knumv TYPE knumv,

cnty TYPE kschl,
amount TYPE kbetr,
crcy TYPE waers,
* amountbis TYPE kbetr,
* crcybis TYPE waers,
END OF type.

DATA : struct TYPE type,
table TYPE STANDARD TABLE OF type,

ld_comm_head_i TYPE komk,
table_komv TYPE STANDARD TABLE OF komv,
nbcmdresult TYPE i.
ENDCLASS.

*---------------------------------------------------------------------*
* Implementations
*---------------------------------------------------------------------*

CLASS cmd IMPLEMENTATION.
METHOD getkonv.
CALL FUNCTION 'RV_KONV_SELECT'
EXPORTING
comm_head_i = ld_comm_head_i
TABLES
tkomv = table_komv.
ENDMETHOD.

METHOD getcmdresult.
SELECT vbak~vbeln vbak~auart kna1~name1 lfa1~name1 vbap~posnr vbap~matnr vbap~kwmeng vbap~vrkme vbak~knumv
INTO TABLE table
FROM vbak
INNER JOIN vbap ON vbak~vbeln = vbap~vbeln
INNER JOIN kna1 ON vbak~kunnr = kna1~kunnr
INNER JOIN lfa1 ON vbak~zzlifnr = lfa1~lifnr
WHERE vbak~vbeln IN s_vbeln.
ENDMETHOD.

METHOD getnbcmdresult.
nbcmdresult = sy-dbcnt.
ENDMETHOD.

METHOD printnbcmdresult.
WRITE : 'Number of results of the request : ', nbcmdresult.
ENDMETHOD.

METHOD printcmdresult.
DATA lastorder TYPE i VALUE 0.

DATA w_vbeln TYPE vbak-vbeln.
SORT table BY vbeln.

LOOP AT table INTO struct.
IF lastorder NE struct-vbeln.
lastorder = struct-vbeln.
ld_comm_head_i-knumv = struct-knumv.
getkonv( ).

WRITE : struct-vbeln,
struct-auart,
struct-name1,
struct-name1bis.
SKIP 1.
ENDIF.

WRITE : '_____'.
WRITE : struct-posnr,
struct-matnr,
struct-kwmeng,
struct-vrkme.
* struct-kschl.
SKIP 1.
ENDLOOP.
ENDMETHOD.

METHOD main.
CALL SELECTION-SCREEN 100.

IF sy-subrc = 0.
DATA : result TYPE REF TO cmd.
CREATE OBJECT : result.

result->getcmdresult( ).
result->getnbcmdresult( ).
result->printnbcmdresult( ).
SKIP 1.
result->printcmdresult( ).
ENDIF.
ENDMETHOD.
ENDCLASS.

*---------------------------------------------------------------------*
* Program events
*---------------------------------------------------------------------*

START-OF-SELECTION.
cmd=>main( ).

I began but I can't finish it. Someone can help me ?

3 REPLIES 3

horst_keller
Product and Topic Expert
Product and Topic Expert

Jelena
Active Contributor
0 Kudos

But what exactly is the challenge here? Sorry but "I don't know" is not a question. What have you tried to get to know this and why that didn't work out for you?

Also why do you have to use this FM if you can just read KONV in this context? This FM is not released to the customers. You're exercising something that ABAPers technically should not be doing in real life.

vinita_kasliwal
Active Contributor
0 Kudos

HI Damien

Though I havent read through your entire code here is how you can call the Function module in the below code snippet.

I strongly recommend you to go through the ABAP basics. There are easier ways to call the FM by using patten and where used lists (Pl google if you did not undertsand what I meant)

Kindly try this out and see if it helps

DATA: lt_tkomv TYPE STANDARD TABLE OF KOMV,
ls_tkomv TYPE KOMV,
lv_comm_head_i type KOMK,
cnty type KSCHA,
amount type KBETR,

crcy type WAERS.


CALL FUNCTION 'RV_KONV_SELECT'
EXPORTING
comm_head_i = lv_comm_head_i // Add the value here whatever you are trying to pass in this FM call-fm.png
* COMM_ITEM_I =
* GENERAL_READ = ' '
* READ_CONDITION_RECORD = ' '
* NO_PRESTEP = ' '
* IMPORTING
* COMM_HEAD_E =
tables
tkomv = lt_tkomv
.

Loop at lt_tkomv into ls_tkomv.
cnty = ls_tkomv-kschl.
amount = ls_tkomv-kbetr .
crcy = ls_tkomv-waers .

endloop.

let me know if that helps ..!

Regards

Vinita