How do I use the "call transaction 'se11' and skip first screen" to activate the search box in ABAP? - abap

What I am trying to do is use
Set Parameter ID 'DTB' Field 'z*'.
Call Transaction 'SE11' and skip First Screen.
At this point I want to activate the search box and take the results into an internal table. Any thoughts? Or is there a way to use the data base statistics to pull this information faster?

Instead of accessing the tables directly, you may want to use a semi-official API that not only handles the activation state, but also takes permissions into account as well:
DATA: lt_tables TYPE STANDARD TABLE OF rpy_tabl.
FIELD-SYMBOLS: <ls_table> TYPE rpy_tabl.
CALL FUNCTION 'RPY_TABLE_SELECT'
EXPORTING
table_name = 'Z*'
TABLES
tabl_inf_tab = lt_tables
EXCEPTIONS
cancelled = 1
not_found = 2
permission_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
* Implement suitable error handling here
ELSE.
LOOP AT lt_tables ASSIGNING <ls_table>.
CASE <ls_table>-tablclass.
WHEN 'TRANSP'. " Transparent table
* ...
WHEN 'INTTAB'. " Structure
* ...
WHEN 'CLUSTER'. " Cluster table
* ...
WHEN 'POOL'. " Pooled table
* ...
WHEN 'VIEW'. " Generated view structure
* ...
WHEN 'APPEND'. " Append structure
* ...
ENDCASE.
ENDLOOP.
ENDIF.

The code below will get what you want, you might need to add some more where clauses to only get active tables (AS4LOCAL EQ 'A')or only transparent tables (TABCLASS EQ 'TRANSP') since this table also contains structures.
DATA: t_tabname TYPE STANDARD TABLE OF tabname.
SELECT tabname INTO TABLE t_tabname FROM dd02l WHERE tabname LIKE 'Z%'.

Related

I don't understand how READ TABLE inside LOOP works

In my code I need to iterate inside a loop, and for each iteration in the loop I have to fill in the data whose values ​​are different in certain cells.
Reading the sap documentation I have come to the conclusion that what I need is to use a read table to fill for each iteration into a working area that later I'll treat.
I have declarated the following tables:
it_sap with the content of a join from VBRK and VBRP tables
wa_sap as working area
it_ext with content from an another join from an external database
wa_ext as working area.
This is how my loop looks actually like:
LOOP AT it_sap INTO wa_sap.
wa_sap-tipo_documento = wa_sap-xblnr+2(1). " Linea
tiket = wa_sap-xblnr+9(7).
creationyear = wa_sap-fkdat+0(4).
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = tiket
IMPORTING
output = tiket.
CONCATENATE creationyear '/' wa_sap-vkorg wa_sap-xblnr+7(2) '/' tiket INTO wa_sap-codalb.
"CLEAR position.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = wa_sap-posnr
IMPORTING
output = position.
READ TABLE it_ext INTO wa_ext
WITH KEY codalb = wa_ext-codalb
tipo_documento = wa_ext-tipo_documento.
IF sy-subrc = 0.
wa_sap-import_total = wa_ext-import_total.
wa_sap-import = wa_ext-import.
wa_sap-price = wa_ext-price.
wa_sap-price_total = wa_ext-price_total.
wa_sap-disccount = wa_ext-disccount.
wa_sap-quantity = wa_ext-quantity.
MODIFY it_sap FROM wa_sap.
IF wa_sap-importe_total <> wa_sap-netwr. "AND position = 1 .
APPEND wa_sap TO it_results.
ENDIF.
ENDIF.
ENDLOOP.
How does it work? I understand that by using the conditional sy-subrc = 0 I can see if the previous statement gives true or false but I don't quite understand how it works by using READ instead SELECT steament.
Thank you guys!
LOOP AT iterates over all rows of an internal table.
READ TABLE retrieves at most one row from an internal table.
sy-subrc provides you details about how well the previous statement worked. Its values differ with the statement. In case of READ TABLE, it tells you whether a row was found (= 0) or not (<> 0). The IF sy-subrc = 0 after your READ TABLE thus means "if you found such a row".
It's hard to understand what your code is supposed to do and whether it does that correctly without some helpful sample data. As József Szikszai points out in the comments to your question, the READ TABLE's conditions rely on wa_ext, which is never filled in your sample code, so at first glance this looks like it's not working at all or your sample does not include some initialisation code.

cmd_ei_api=>maintain_bapi to update kna1 table field (ICMSTAXPAY)

I have a requirement to update this field ICMSTAXPAY in KNA1 table using my custom report. So, I tried using cmd_ei_api=>maintain_bapi to update the table. But once I run the program, that particular field is not updated and I don't get any error messages too.
My logic:
Read the KNA1 entries.
Edit the required field to my value.
Pass mandatory data to HEADER for update.
Pass my new KNA1 entries to CENTRAL_DATA.
Read data from table:
CALL METHOD cmd_ei_api_memory=>get_global_kna1
EXPORTING
iv_kunnr = <lfs_final>-kunnr
IMPORTING
es_kna1_old = ls_old.
Change the value of field:
ls_old-icmstaxpay = 9.
MOVE-CORRESPONDING ls_old TO ls_customer-central_data-central-data.
Assign header data:
ls_customer-header-object_instance-kunnr = <lfs_final>-kunnr.
ls_customer-header-object_task = 'U'.
Add all the above to the master data structure:
APPEND ls_customer TO lt_customers[].
ls_master_data-customers = lt_customers[].
Pass the data and update to table:
cmd_ei_api=>initialize( ).
LOOP AT lt_customers INTO ls_customer.
cmd_ei_api=>lock( iv_kunnr = ls_customer-header-object_instance-kunnr ).
ENDLOOP.
" Update Customer with CMD_EI_API
CALL METHOD cmd_ei_api=>maintain_bapi
EXPORTING
iv_test_run = space
is_master_data = ls_master_data
IMPORTING
es_message_defective = ls_message_defective.
IF ls_message_defective IS INITIAL.
BREAK-POINT.
COMMIT WORK.
ELSE.
BREAK-POINT.
ENDIF.
LOOP AT lt_customers INTO ls_customer.
cmd_ei_api=>unlock( iv_kunnr = ls_customer-header-object_instance-kunnr ) .
ENDLOOP.
When I debug, I can see that the entry that is being fetched for update is the old entry that is present in the current memory.
Please let me know if i am doing something wrong while passing the value to the table.
You need including DATAX with X for all fields that you need change.
DATA: ls_datax TYPE cmds_ei_vmd_central_data_xflag.
ls_datax-icmstaxpay = 'X'.
MOVE ls_datax TO ls_customer-central_data-central-datax.
And thanx for your question, helped me with find this methody :)

Creating documentary batches programmatically with BAPI_GOODSMVT_CREATE?

Summary of the problem
Automatic Documentary Batch handling through custom ABAP code
My employer wishes to perform automatic documentary batch handling on some products from external vendors, and I'm trying to figure out how to set this up through Customizing and ABAP.
It seems to me that Documentary Batches are only meant to be used through MIGO - in any case I'm unable to find a proper solution to assign them programatically, and any hacked-together solution I can come up with, seems insufficient and unstable.
What avenues do I have to solve this issue?
Enhancing BAPI_GOODSMVT_CREATE?
Can I somehow do it through stuff like BAPI_GOODSMVT_CREATE?
Enhancing PPPI Message Destinations?
I also specifically need it to work for consumption messaging through PPPI, and I thought to build on top of the standard Message Destination PI04, FM COCI_CONFIRM_MATERIAL_CONS.
This FM creates a Material Document but does not go through the BAPI_GOODSMVT_CREATE FM.
It does however use MB_CREATE_GOODS_MOVEMENT.
What I've already tried
MIGO Snapshot based Single Use hack solution
I made hack-solution for one area, where I watched which table-updates MIGO performed and with which data (through FM's VB_INSERT_BATCH and VB_BATCH_WHERE_USED_LIST), and then filled out these structures manually.
However, providing all the needed info is not feasible for other implementation areas, as they do not have all the necessary values available, and it doesn't cover unforeseen situations where other parameters might be required.
Reading through BAPI_GOODSMVT_CREATE code
I've tried spying on whether BAPI_GOODSMVT_CREATE performs the same FM's but only found it accessing VB_BATCH_WHERE_USED_LIST.
It seems to be possible to activate this functionality by controlling Memory ID Documentary Batch #1, Documentary Batch #2, Documentary Batch #3 and Documentary Batch #5 (see FM VBDBDM_DATA_POST_IM), but this requires filling out a lot data, including the structure named DOCUBATCH_SCREEN_FIELDS, which again makes it seem like this might not be the correct avenue of approach.
Regardless, this still doesn't allow me to maintain batch through tables MCHA and MCH1.
Hacked together solution based on MIGO snapshot
Here is how my hacked solution looks. Again, this is not a feasible way to go about the problem, as other implementation areas does not have the resulting Material Document immediately available:
FUNCTION zproxy_mdr_goodsreceipt.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(IS_GOODSRECEIPT_HEAD) TYPE ZPROXY_GOODSREC_HEAD
*" VALUE(IT_GOODSRECEIPT_ITEM) TYPE ZPROXY_GOODSREC_ITEM_T
*" REFERENCE(I_CREATE_TO_FROM_REQUIREMENTS) TYPE FLAG DEFAULT '-'
*" EXPORTING
*" REFERENCE(E_GOODSMVT_MSG_IDNO) TYPE CHAR23
*" REFERENCE(E_MBLNR) TYPE MBLNR
*" REFERENCE(E_TO_CREATION_SUBRC) TYPE SY-SUBRC
*" REFERENCE(E_LGNUM_ERROR) TYPE LGNUM
*" REFERENCE(E_TBNUM_ERROR) TYPE TBNUM
*" REFERENCE(E_DOCBATCH_SUBRC) TYPE SY-SUBRC
*" REFERENCE(E_DOCBATCH_MSG_IDNO) TYPE CHAR23
*" REFERENCE(E_CLASSNUM) TYPE BAPI1003_KEY-CLASSNUM
*" REFERENCE(E_OBJKEY) TYPE BAPI1003_KEY-OBJECT
*" EXCEPTIONS
*" GOODSMVT_FAILED
*" NO_TRANSFER_REQUIREMENTS
*" TRANSFER_ORDER_CREATION_ERROR
*"----------------------------------------------------------------------
FIELD-SYMBOLS: <return> TYPE bapiret2,
<goods_rec_item> TYPE zproxy_goodsrec_item,
<mseg> TYPE mseg,
<char_char> TYPE bapi1003_alloc_values_char,
<ltap_creat> TYPE LTAP_CREAT.
DATA: ls_header TYPE bapi2017_gm_head_01,
ls_code TYPE bapi2017_gm_code,
ls_item TYPE bapi2017_gm_item_create,
lt_item TYPE STANDARD TABLE OF bapi2017_gm_item_create,
lt_return TYPE STANDARD TABLE OF bapiret2,
ls_headret TYPE bapi2017_gm_head_ret,
l_mblnr LIKE bapi2017_gm_head_ret-mat_doc,
l_docubatch TYPE charg_d,
l_subrc TYPE sy-subrc,
lt_mseg TYPE STANDARD TABLE OF mseg.
CLEAR l_subrc.
* ############################## Create goods movement ##############################
* Build structures
MOVE-CORRESPONDING is_goodsreceipt_head TO ls_header.
ls_code-gm_code = '01'.
LOOP AT it_goodsreceipt_item ASSIGNING <goods_rec_item>.
MOVE-CORRESPONDING <goods_rec_item> TO ls_item.
APPEND ls_item TO lt_item.
ENDLOOP.
* BAPI call
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = ls_header
goodsmvt_code = ls_code
IMPORTING
goodsmvt_headret = ls_headret
materialdocument = l_mblnr
TABLES
goodsmvt_item = lt_item
return = lt_return.
* Check errors
READ TABLE lt_return ASSIGNING <return> WITH KEY type = 'E'.
IF sy-subrc = 0.
e_goodsmvt_msg_idno = <return>-id && <return>-number.
ROLLBACK WORK.
RAISE goodsmvt_failed.
ELSE.
e_mblnr = l_mblnr.
COMMIT WORK AND WAIT. "Wait for TO requirements to be created
ENDIF.
* Only proceede if Material Document has been successfully posted
CHECK l_subrc = 0 AND l_mblnr IS NOT INITIAL.
* ############################## Update with Documentary Batch ###################################
DATA: lt_chvw TYPE STANDARD TABLE OF chvw,
ls_chvw TYPE chvw,
lt_mch1 TYPE STANDARD TABLE OF mch1,
ls_mch1 TYPE mch1,
lt_mcha TYPE STANDARD TABLE OF mcha,
ls_mcha TYPE mcha,
lt_mchb TYPE STANDARD TABLE OF mchb,
lt_mska TYPE STANDARD TABLE OF mska,
lt_mspr TYPE STANDARD TABLE OF mspr,
lt_char_num TYPE STANDARD TABLE OF bapi1003_alloc_values_num,
lt_char_char TYPE STANDARD TABLE OF bapi1003_alloc_values_char,
lt_char_curr TYPE STANDARD TABLE OF bapi1003_alloc_values_curr,
l_objkey TYPE bapi1003_key-object,
l_classnum TYPE bapi1003_key-classnum,
l_atnam TYPE atnam.
REFRESH lt_chvw.
* Get material document items
SELECT *
FROM mseg
INTO TABLE lt_mseg
WHERE mblnr = l_mblnr.
* Perpare docubatch registration data
LOOP AT it_goodsreceipt_item ASSIGNING <goods_rec_item>.
* Generate class num and atnam from plant
CONCATENATE 'PI_' <goods_rec_item>-plant INTO l_classnum.
CONCATENATE 'Z_DOC_BATCH_' <goods_rec_item>-plant INTO l_atnam.
* Get material docubatch usage characteristic
REFRESH: lt_return,
lt_char_num,
lt_char_char,
lt_char_curr.
l_objkey(18) = <goods_rec_item>-material.
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL'
EXPORTING
objectkey = l_objkey
objecttable = 'MARA'
classnum = l_classnum
classtype = '001'
TABLES
allocvaluesnum = lt_char_num
allocvalueschar = lt_char_char
allocvaluescurr = lt_char_curr
return = lt_return.
LOOP AT lt_return ASSIGNING <return> WHERE type = 'E'. "Check for errors
* Couldn't read characteristic, assume no docubatch handling
e_docbatch_subrc = '1'.
e_docbatch_msg_idno = <return>-id && <return>-number.
e_classnum = l_classnum.
e_objkey = l_objkey.
CONTINUE.
ENDLOOP.
READ TABLE lt_char_char ASSIGNING <char_char> WITH KEY charact = l_atnam.
IF sy-subrc <> 0 OR <char_char>-value_neutral = 0.
* No docubatch value
CONTINUE.
ENDIF.
* Get associated material document item
READ TABLE lt_mseg ASSIGNING <mseg>
WITH KEY mblnr = ls_headret-mat_doc
mjahr = ls_headret-doc_year
bwart = <goods_rec_item>-move_type
matnr = <goods_rec_item>-material
werks = <goods_rec_item>-plant
menge = <goods_rec_item>-entry_qnt
meins = <goods_rec_item>-entry_uom
hsdat = <goods_rec_item>-prod_date
kzbew = <goods_rec_item>-mvt_ind
lgort = <goods_rec_item>-stge_loc.
IF sy-subrc <> 0.
* No associated material document item
CONTINUE.
ENDIF.
* Check docubatch type
IF <char_char>-value_neutral <> 0.
* Perform basic docubatch actions (MCHA and MCH1)
* Verify that docubatch nr is assigned
IF <goods_rec_item>-vendrbatch IS INITIAL.
* !!!!!!!!!!!!! Venderbatch not filled even though material is docubatch managed, what to do? !!!!!!!!!!!!!!!
CONTINUE.
ENDIF.
* Prepare data for docubatch registration
CLEAR: ls_mch1,
ls_mcha.
ls_mch1-matnr = <goods_rec_item>-material.
ls_mch1-charg = <goods_rec_item>-vendrbatch.
ls_mch1-ersda = sy-datum.
ls_mch1-ernam = sy-uname.
ls_mch1-ersda_tmstp = sy-datum && sy-uzeit.
ls_mch1-ersda_tz_sys = sy-tzone.
ls_mch1-ersda_tz_usr = sy-zonlo.
MOVE-CORRESPONDING ls_mch1 TO ls_mcha. "Same fields from MCH1 are included in MCHA
ls_mcha-werks = <goods_rec_item>-plant.
APPEND: ls_mch1 TO lt_mch1,
ls_mcha TO lt_mcha.
ENDIF.
IF <char_char>-value_neutral = 2. "Also include batch where-used
* Perpare data for batch where-used registration
CLEAR ls_chvw.
ls_chvw-matnr = <goods_rec_item>-material.
ls_chvw-werks = <goods_rec_item>-plant.
ls_chvw-charg = <goods_rec_item>-vendrbatch.
ls_chvw-ebeln = <goods_rec_item>-po_number.
ls_chvw-ebelp = <goods_rec_item>-po_item.
ls_chvw-mblnr = ls_headret-mat_doc.
ls_chvw-mjahr = ls_headret-doc_year.
ls_chvw-zeile = <mseg>-zeile.
ls_chvw-budat = is_goodsreceipt_head-pstng_date.
ls_chvw-shkzg = 'S'. "??? VALUE ???
ls_chvw-bwart = <goods_rec_item>-move_type.
ls_chvw-kzbew = <goods_rec_item>-mvt_ind. "Goods Movement for Purchase Order
ls_chvw-menge = <goods_rec_item>-entry_qnt.
ls_chvw-meins = <goods_rec_item>-entry_uom.
APPEND ls_chvw TO lt_chvw.
ENDIF.
ENDLOOP.
* Perform batch registration
CALL FUNCTION 'VB_INSERT_BATCH'
TABLES
zmch1 = lt_mch1
zmcha = lt_mcha
zmchb = lt_mchb
zmska = lt_mska
zmspr = lt_mspr
.
* Perform batch where-used registration
CALL FUNCTION 'VB_BATCH_WHERE_USED_LIST'
TABLES
xchvw = lt_chvw.
Why this isn't good enough, and what I need
This performs as a snapshot of MIGO configured with documentary batch handling, but doesn't necessarily cover all cases.
It only works in the context of a Purchase Document, and doesn't cover other cases such as Orders and Sales Orders.
Additionally I only have the necessary date because of the material document being created immediately above, which is not possible for all implementation cases.
I would like to know if there is an intended way to perform Documentary Batch handling from custom code.
Quoting from the documentation:
If you work with RFID or TRM functions, or call IDocs/BAPIs, you can only book in documentary
batches by calling up the RFC-capable function module VBDBDM_DATA_MAINTAIN_RFC
beforehand or incorporating it into the process.
So maybe this function module is the key?
However, it seems you may not be the first to experience this pain. A comment on that documentation reads:
Documentary Batch has a lot of constraints and it seems to be a semifinished product of SAP, since is missing a lot of features of real batches.
Be prepared to make a lot of custom enhancements...
ADDENDUM from community: below is the solution taken from the Original Poster two days after this answer, moved away from his question.
Solution
Example call for Purchase Order Goods Receipt
LOOP AT it_goodsreceipt_item ASSIGNING <goods_rec_item>.
CALL FUNCTION 'VBDBDM_DATA_MAINTAIN_RFC'
EXPORTING
i_matnr = <goods_rec_item>-material
i_werks = <goods_rec_item>-plant
i_quantity = <goods_rec_item>-entry_qnt
i_uom = <goods_rec_item>-entry_uom
i_docubatch_charg = <goods_rec_item>-vendrbatch
* IT_DOCUBATCHES =
i_process_id = '01' "Goods Receipt for External Procurement
* I_REPLACE_EXISTING_DATA =
i_ebeln = <goods_rec_item>-po_number
i_ebelp = <goods_rec_item>-po_item
* I_AUFNR =
* I_AUFPS =
* I_RSNUM =
* I_RSPOS =
* I_RSART =
* I_VBELN =
* I_POSNR =
* IS_DOCUBATCH_COM =
* I_LINE_ID =
* I_LGNUM =
* I_TANUM =
* I_TAPOS =
EXCEPTIONS
parameter_error = 1
process_not_active = 2.
ENDLOOP.
* Follow up by creating Material Document, for example through BAPI_GOODSMVT_CREATE

Change field length afterwards

TABLES: VBRK.
DATA: BEGIN OF it_test,
BUKRS LIKE VBRK-BUKRS,
FKDAT LIKE VBRK-FKDAT,
END OF it_test.
DATA: wa_test LIKE it_test.
SELECT * FROM VBRK INTO CORRESPONDING FIELD OF wa_test.
IF wa_test-BUKRS = 'xxxx'.
wa_test-BUKRS = 'XXXXX' "Problem occurs here as the BUKRS allow 4 value
APPEND wa_test TO it_test.
ENDIF.
Then I want to map the internal table to output as ALV table. Is they any way to change the field length afterwards?
Apart from multiple issues in your code, you can't. If you need something similar to that, add an additional field to the structure with whatever size you require and copy the values over.
If the objective is to output something to the screen that is different(or differently formatted) that what is stored internally(or in the database), then the use of a data element with a conversion exit maybe the way to go.
For an example, look at the key fields of table PRPS.
Expanding the answer of vwegert:
The MOVE-CORRESPONDINGcommand (and SELECT ... INTO CORRESPONDING FIELDS) don't need the same field type. The content is converted. So you could define a 5-character field in your internal structure and copy the BUKRS-value into this 5-character field:
TABLES: VBRK.
DATA: BEGIN OF it_test,
BUKRS(5), "longer version of VBRK-BUKRS,
FKDAT LIKE VBRK-FKDAT,
END OF it_test.
DATA: tt_test TYPE STANDARD TABLE OF it_test.
* I would strongly recommend to set a filter!
SELECT * FROM VBRK INTO CORRESPONDING FIELD OF it_test.
IF it_test-BUKRS = 'xxxx'.
it_test-BUKRS = 'XXXXX'.
APPEND it_test to tt_test.
ENDIF.
ENDSELECT.
A pitfall: When you use it with ALV you will loose the field description. (on the other side, the field description of the original field will not fit any longer the new field.)

How to get rows count of internal table in abap?

How do I get the row count of an internal table? I guess that I can loop on it. But there must be a saner way.
I don't know if it makes a difference but the code should run on 4.6c version.
There is also a built-in function for this task:
variable = lines( itab_name ).
Just like the "pure" ABAP syntax described by IronGoofy, the function "lines( )" writes the number of lines of table itab_name into the variable.
You can use the following function:
DESCRIBE TABLE <itab-Name> LINES <variable>
After the call, variable contains the number of rows of the internal table .
Beside the recommended
DESCRIBE TABLE <itab-Name> LINES <variable>
there is also the system variable SY-TFILL.
From documentation:
After the statements DESCRIBE TABLE, LOOP AT and READ TABLE, the number of rows of the accessed internal table.
Example script:
REPORT ytest.
DATA pf_exclude TYPE TABLE OF sy-ucomm WITH HEADER LINE.
START-OF-SELECTION.
APPEND '1' TO pf_exclude.
APPEND '2' TO pf_exclude.
APPEND '3' TO pf_exclude.
APPEND '4' TO pf_exclude.
WRITE: / 'sy-tfill = ', sy-tfill.
DESCRIBE TABLE pf_exclude.
WRITE: / 'sy-tfill = ', sy-tfill, 'after describe table'.
sy-tfill = 0. "Reset
READ TABLE pf_exclude INDEX 1 TRANSPORTING NO FIELDS.
WRITE: / 'sy-tfill = ', sy-tfill, 'after read table'.
sy-tfill = 0. "Reset
LOOP AT pf_exclude.
WRITE: / 'sy-tfill = ', sy-tfill, 'in loop with', pf_exclude.
sy-tfill = 0. "Reset
ENDLOOP.
The result:
sy-tfill = 0
sy-tfill = 4 after describe tabl
sy-tfill = 4 after read table
sy-tfill = 4 in loop with 1
sy-tfill = 0 in loop with 2
sy-tfill = 0 in loop with 3
sy-tfill = 0 in loop with 4
Please get attention of the value 0 for the 2nd entry: SY-TFILL is not updated with each step, only after the first loop.
I recommend the usage SY-TFILL only, if you need it direct after the READ(1)... If there are other commands between the READ and the usage of SY-TFILL, there is always the danger of a change of the system variable.
(1) or describe table.
DATA : V_LINES TYPE I. "declare variable
DESCRIBE TABLE <ITAB> LINES V_LINES. "get no of rows
WRITE:/ V_LINES. "display no of rows
Refreance:
http://www.sapnuts.com/courses/core-abap/internal-table-work-area.html
The functional module EM_GET_NUMBER_OF_ENTRIES will also provide the row count. It takes 1 parameter - the table name.
you can also use OPEN Sql to find the number of rows using the COUNT Grouping clause and also there is system field SY-LINCT to count the lines(ROWS) of your table.
if I understand your question correctly, you want to know the row number during a conditional loop over an internal table.
You can use the system variable sy-tabix if you work with internal tables. Please refer to the ABAP documentation if you need more information (especially the chapter on internal table processing).
Example:
LOOP AT itab INTO workarea
WHERE tablefield = value.
WRITE: 'This is row number ', sy-tabix.
ENDLOOP.
data: vcnt(4).
clear vcnt.
LOOP at itab WHERE value = '1'.
add 1 to vcnt.
ENDLOOP.
The answer will be 3. (vcnt = 3).
I don't think there is a SAP parameter for that kind of result. Though the code below will deliver.
LOOP AT intTab.
AT END OF value.
result = sy-tabix.
write result.
ENDAT.
ENDLOOP.