<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Reduce Lines of Code - Using ASSIGN ? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/reduce-lines-of-code-using-assign/m-p/5756121#M1304010</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Solved&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 29 Jun 2009 13:33:51 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-06-29T13:33:51Z</dc:date>
    <item>
      <title>Reduce Lines of Code - Using ASSIGN ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reduce-lines-of-code-using-assign/m-p/5756118#M1304007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please guide me in achieving this. Please find the below code for example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;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.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;zmm_s_mat_rep - Structure(Screen 110)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Chandan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jun 2009 05:42:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reduce-lines-of-code-using-assign/m-p/5756118#M1304007</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-29T05:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: Reduce Lines of Code - Using ASSIGN ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reduce-lines-of-code-using-assign/m-p/5756119#M1304008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Chandan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can reduce number of lines simply by&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;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.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this resolves your query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Manish&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Manish  Bisht on Jun 29, 2009 7:46 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Manish  Bisht on Jun 29, 2009 7:47 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jun 2009 05:46:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reduce-lines-of-code-using-assign/m-p/5756119#M1304008</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-29T05:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: Reduce Lines of Code - Using ASSIGN ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reduce-lines-of-code-using-assign/m-p/5756120#M1304009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN __default_attr="blue" __jive_macro_name="color"&gt;Hi Chandan,

&lt;PRE&gt;&lt;CODE&gt;ASSIGN mem_area TO &amp;lt;fs&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;
&amp;lt;li&amp;gt;This statement assigns the memory area specified using mem_area to the field symbol &amp;lt;fs&amp;gt;. 
&amp;lt;li&amp;gt;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.
&lt;PRE&gt;&lt;CODE&gt;
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.

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  GET_qty
*&amp;amp;---------------------------------------------------------------------*
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&lt;/CODE&gt;&lt;/PRE&gt;

Thanks
Venkat.O&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jun 2009 06:01:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reduce-lines-of-code-using-assign/m-p/5756120#M1304009</guid>
      <dc:creator>venkat_o</dc:creator>
      <dc:date>2009-06-29T06:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: Reduce Lines of Code - Using ASSIGN ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reduce-lines-of-code-using-assign/m-p/5756121#M1304010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Solved&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jun 2009 13:33:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reduce-lines-of-code-using-assign/m-p/5756121#M1304010</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-29T13:33:51Z</dc:date>
    </item>
  </channel>
</rss>

