2009 Jun 29 6:42 AM
Hi All,
My requirement is very simple, I just want to reduce my lines of code. I came to know, this can be done by using ASSIGN statement.
Please guide me in achieving this. Please find the below code for example.
CASE ok_code.
WHEN 'EXEC'.
SELECT SINGLE matnr FROM mara INTO gwa_0110_val
WHERE matnr EQ zmm_s_mat_rep-new_material.
IF sy-subrc EQ 0.
IF gv_count = 0.
gwa_0110-new_mat1 = zmm_s_mat_rep-new_material.
gwa_0110-new_qty1 = zmm_s_mat_rep-new_qty.
gwa_0110-line_no = tc110-current_line.
IF gv_sel1 = 'X'.
gwa_0110-sel1 = 'X'.
ENDIF.
ENDIF.
IF gv_count = 1.
gwa_0110-new_mat2 = zmm_s_mat_rep-new_material.
gwa_0110-new_qty2 = zmm_s_mat_rep-new_qty.
gwa_0110-line_no = tc110-current_line.
IF gv_sel1 = 'X'.
gwa_0110-sel1 = 'X'.
ENDIF.
ENDIF.
IF gv_count = 2.
gwa_0110-new_mat3 = zmm_s_mat_rep-new_material.
gwa_0110-new_qty3 = zmm_s_mat_rep-new_qty.
gwa_0110-line_no = tc110-current_line.
IF gv_sel1 = 'X'.
gwa_0110-sel1 = 'X'.
ENDIF.
ENDIF.
IF gv_count = 3.
gwa_0110-new_mat4 = zmm_s_mat_rep-new_material.
gwa_0110-new_qty4 = zmm_s_mat_rep-new_qty.
gwa_0110-line_no = tc110-current_line.
IF gv_sel1 = 'X'.
gwa_0110-sel1 = 'X'.
ENDIF.
ENDIF.
IF gv_count = 4.
gwa_0110-new_mat5 = zmm_s_mat_rep-new_material.
gwa_0110-new_qty5 = zmm_s_mat_rep-new_qty.
gwa_0110-line_no = tc110-current_line.
IF gv_sel1 = 'X'.
gwa_0110-sel1 = 'X'.
ENDIF.
ENDIF.
ELSE.
MESSAGE i014(z_mm_prox).
ENDIF.
CLEAR gwa_0110_val.
APPEND gwa_0110 TO git_0110.
CLEAR gwa_0110.zmm_s_mat_rep - Structure(Screen 110)
Thanks,
Chandan
Hi All,
My requirement is very simple, I just want to reduce my lines of code. I came to know, this can be done by using ASSIGN statement.
Please guide me in achieving this. Please find the below code for example.
CASE ok_code.
WHEN 'EXEC'.
SELECT SINGLE matnr FROM mara INTO gwa_0110_val
WHERE matnr EQ zmm_s_mat_rep-new_material.
IF sy-subrc EQ 0.
IF gv_count = 0.
gwa_0110-new_mat1 = zmm_s_mat_rep-new_material.
gwa_0110-new_qty1 = zmm_s_mat_rep-new_qty.
gwa_0110-line_no = tc110-current_line.
IF gv_sel1 = 'X'.
gwa_0110-sel1 = 'X'.
ENDIF.
ENDIF.
IF gv_count = 1.
gwa_0110-new_mat2 = zmm_s_mat_rep-new_material.
gwa_0110-new_qty2 = zmm_s_mat_rep-new_qty.
gwa_0110-line_no = tc110-current_line.
IF gv_sel1 = 'X'.
gwa_0110-sel1 = 'X'.
ENDIF.
ENDIF.
IF gv_count = 2.
gwa_0110-new_mat3 = zmm_s_mat_rep-new_material.
gwa_0110-new_qty3 = zmm_s_mat_rep-new_qty.
gwa_0110-line_no = tc110-current_line.
IF gv_sel1 = 'X'.
gwa_0110-sel1 = 'X'.
ENDIF.
ENDIF.
IF gv_count = 3.
gwa_0110-new_mat4 = zmm_s_mat_rep-new_material.
gwa_0110-new_qty4 = zmm_s_mat_rep-new_qty.
gwa_0110-line_no = tc110-current_line.
IF gv_sel1 = 'X'.
gwa_0110-sel1 = 'X'.
ENDIF.
ENDIF.
IF gv_count = 4.
gwa_0110-new_mat5 = zmm_s_mat_rep-new_material.
gwa_0110-new_qty5 = zmm_s_mat_rep-new_qty.
gwa_0110-line_no = tc110-current_line.
IF gv_sel1 = 'X'.
gwa_0110-sel1 = 'X'.
ENDIF.
ENDIF.
ELSE.
MESSAGE i014(z_mm_prox).
ENDIF.
CLEAR gwa_0110_val.
APPEND gwa_0110 TO git_0110.
CLEAR gwa_0110.zmm_s_mat_rep - Structure(Screen 110)
Thanks,
Chandan
2009 Jun 29 6:46 AM
Hi Chandan,
You can reduce number of lines simply by
CASE ok_code.
WHEN 'EXEC'.
SELECT SINGLE matnr FROM mara INTO gwa_0110_val
WHERE matnr EQ zmm_s_mat_rep-new_material.
IF sy-subrc EQ 0.
IF ( gv_count eq 0 ) or
( gv_count eq 1) or
( gv_count eq 2 ) or
( gv_count eq 3 ) or
( gv_count eq 4 ).
gwa_0110-new_mat1 = zmm_s_mat_rep-new_material.
gwa_0110-new_qty1 = zmm_s_mat_rep-new_qty.
gwa_0110-line_no = tc110-current_line.
IF gv_sel1 = 'X'.
gwa_0110-sel1 = 'X'.
ENDIF.
ENDIF.
ELSE.
MESSAGE i014(z_mm_prox).
ENDIF.Hope this resolves your query.
Regards,
Manish
Edited by: Manish Bisht on Jun 29, 2009 7:46 AM
Edited by: Manish Bisht on Jun 29, 2009 7:47 AM
2009 Jun 29 7:01 AM
Hi Chandan,
<li>This statement assigns the memory area specified using mem_area to the field symbol <fs>.
<li>You can use modify your code like this. There is no wrong in your code actually. I dont understand what the problem is in your code.
ASSIGN mem_area TO <fs>.
Thanks
Venkat.O
ASSIGN
CASE ok_code.
WHEN 'EXEC'.
SELECT SINGLE matnr FROM mara INTO gwa_0110_val
WHERE matnr EQ zmm_s_mat_rep-new_material.
IF sy-subrc EQ 0.
CASE gv_count.
WHEN 0.
PERFORM get_qty CHANGING gwa_0110-new_mat1
gwa_0110-new_qty1
gwa_0110-line_no
gwa_0110-sel1.
WHEN 1.
PERFORM get_qty CHANGING gwa_0110-new_mat1
gwa_0110-new_qty1
gwa_0110-line_no
gwa_0110-sel1.
WHEN 2.
PERFORM get_qty CHANGING gwa_0110-new_mat1
gwa_0110-new_qty1
gwa_0110-line_no
gwa_0110-sel1.
WHEN 3.
PERFORM get_qty CHANGING gwa_0110-new_mat1
gwa_0110-new_qty1
gwa_0110-line_no
gwa_0110-sel1.
WHEN 4.
PERFORM get_qty CHANGING gwa_0110-new_mat1
gwa_0110-new_qty1
gwa_0110-line_no
gwa_0110-sel1.
ENDCASE.
ELSE.
MESSAGE i014(z_mm_prox).
ENDIF.
CLEAR gwa_0110_val.
APPEND gwa_0110 TO git_0110.
CLEAR gwa_0110.
ENDCASE.
*&---------------------------------------------------------------------*
*& Form GET_qty
*&---------------------------------------------------------------------*
FORM get_qty CHANGING mat qty line_no sel.
mat = zmm_s_mat_rep-new_material.
qty = zmm_s_mat_rep-new_qty.
line_no = tc110-current_line.
IF gv_sel1 = 'X'.
sel = 'X'.
ENDIF.
ENDFORM. "GET_qty
2009 Jun 29 2:33 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |